You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Most native primitive types, including `str`, cannot be effectively extended in traditional manner -- by invoking `super` in the subclass constructor -- `__new__` must be overriden instead to yield the object of appropriate type because the super-class does not feature a constructor and objects of the class are constructed with e.g. `str.__new__`.
"""See Python's own `IOBase.read` in the `io` module."""
39
39
raiseNotImplementedError
40
40
@@ -78,17 +78,17 @@ class BufferedPeekingReader(PeekingUnreadingReader[T]):
78
78
def__init__(self, source: Reader[T]):
79
79
self._source=source
80
80
self._buffer= []
81
-
defpeek(self, size: int, /) ->Sequence[T]:
82
-
assertsize>=0# Reading with negative sizes is defined by `read` defined by Python, but not implemented yet for this class (that would call for a more elaborate implementation, while the reader is never used with negative values)
81
+
defpeek(self, size: int|None, /) ->Sequence[T]:
82
+
assertsizeisnotNoneandsize>=0# Reading with negative sizes is defined by `read` defined by Python, but not implemented yet for this class (that would call for a more elaborate implementation, while the reader is never used with negative values)
Copy file name to clipboardExpand all lines: src/csspring/values.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
fromcollections.abcimportIterable, Mapping
9
9
fromfunctoolsimportsingledispatchmethod
10
10
importre
11
-
fromtypingimportcast
11
+
fromtypingimportAny, cast
12
12
13
13
classProduction:
14
14
"""An [abstract] class of CSS grammar elements.
@@ -22,7 +22,7 @@ class Production:
22
22
Note that a production is not the same as a [parse] product -- the former is an element of some language grammar, while the latter is a result of parsing a sequence of tokens in accordance with a grammar production, in effect expressing one single element from the set of all permutations a production would permit, corresponding to consumed part of the sequence.
23
23
"""
24
24
name: str
25
-
def__set_name__(self, _, name):
25
+
def__set_name__(self, _: Any, name: str) ->None:
26
26
assertnothasattr(self, "name") orself.name==name# Given the usage context, we don't want to support re-setting the name, not with a different value at least
27
27
self.name=name
28
28
@@ -111,8 +111,8 @@ class TokenProduction(Production):
111
111
"""Class of productions that express a token, optionally one with a matching set of attributes.
:param type: The type of token this production will express
118
118
:param attributes: Mapping of presumably token attribute values by name, to use for expressing the set of attributes on the token this production will express
@@ -136,7 +136,7 @@ def __init__(self, element: Production, min: int = 1, max: int | None = None):
136
136
classFormatter:
137
137
"""Class of objects that offer procedures for serializing productions into streams of text formatted per the [value definition syntax](http://drafts.csswg.org/css-values-4/#value-defs)."""
138
138
grouping_strings= ('[ ', ' ]') # The kind of grouping symbol to use when a production expression must be surrounded with a pair of brace-like grouping symbols, in its serialized form
"""Determine whether a given production shall require an explicit pair of grouping symbols when featured as an _operand_ (e.g. in binary/unary operation context).
141
141
:returns: `True` if the expression of `production` serialized with this formatter, should feature explicit grouping symbols wrapping it, `False` otherwise
0 commit comments