Skip to content

Commit a4d9bfa

Browse files
committed
Satisfy MyPy's 'strict' type checks
This amends those parts of code that wouldn't pass MyPy's "strict" type checking.
1 parent d66362e commit a4d9bfa

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/csspring/syntax/parsing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def normalize_input(input: NormalizeInput) -> Input:
510510
if isinstance(input, Input):
511511
return input
512512
try:
513-
input = iter(cast(Iterable, input))
513+
input = iter(cast(Iterable[Any], input))
514514
except TypeError:
515515
assert not isinstance(input, Iterable) # Communicate to the type checker that `input` is not iterable
516516
else:
@@ -547,7 +547,7 @@ def source(element: Product | Token) -> str:
547547
"""
548548
return element.source if hasattr(element, 'source') else ''.join(source(item) for item in element)
549549

550-
def tokens(product: Iterable | Token) -> Iterator[Token]:
550+
def tokens(product: Product | Token) -> Iterator[Token]:
551551
"""
552552
Yield every token contained in a parser production.
553553

src/csspring/values.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class TokenProduction(Production):
111111
"""Class of productions that express a token, optionally one with a matching set of attributes.
112112
"""
113113
type: type[Token]
114-
attributes: Mapping
114+
attributes: Mapping[str, Any]
115115
def __init__(self, type: builtins.type[Token], **attributes: Any):
116116
"""
117117
:param type: The type of token this production will express
@@ -145,7 +145,7 @@ def grouping_mode(self, production: Production) -> bool:
145145
case ReferenceProduction() | TokenProduction(): return False
146146
case _:
147147
raise ValueError
148-
def combined(self, productions: Iterable, combinator: str) -> Iterable[str]:
148+
def combined(self, productions: Iterable[Production], combinator: str) -> Iterable[str]:
149149
it = (self.format(production) for production in productions)
150150
yield from next(it)
151151
for item in it:

0 commit comments

Comments
 (0)