Skip to content

Commit 2b7b40b

Browse files
committed
Fix an insufficient type cast in the selectors module
The cast was missing the `None` type in union with `Product`, since `parse` _may_ return nothing.
1 parent b930beb commit 2b7b40b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/csspring/selectors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _(production: ConcatenationProduction, input: TokenStream) -> Product | None
106106
@parse.register
107107
def _(production: NonEmptyProduction, input: TokenStream) -> Product | None:
108108
"""Variant of `parse` for productions of the `!` multiplier variety (see https://drafts.csswg.org/css-values-4/#mult-req)."""
109-
result = cast(Product, parse(production.element, input)) # The element of a non-empty production is concatenation, and the `parse` overload for `ConcatenationProduction` never returns a `Token`, only `Product | None`
109+
result = cast(Product | None, parse(production.element, input)) # The element of a non-empty production is concatenation, and the `parse` overload for `ConcatenationProduction` never returns a `Token`, only `Product | None`
110110
if result and any(tokens(result)):
111111
return result
112112
else:

0 commit comments

Comments
 (0)