diff --git a/src/parsita/metaclasses.py b/src/parsita/metaclasses.py index 3e9b516..c3d55ff 100644 --- a/src/parsita/metaclasses.py +++ b/src/parsita/metaclasses.py @@ -18,7 +18,7 @@ @dataclass(frozen=True) class Options: - whitespace: Optional[Parser[Any, Any]] = None + whitespace: Optional[Parser[Any, object]] = None class ParsersDict(dict[str, Any]): @@ -99,7 +99,7 @@ def fwd() -> ForwardDeclaration[Input, Output]: class ParserContextMeta(type): - default_whitespace: Union[Parser[Any, Any], Pattern[str], str, None] = None + default_whitespace: Union[Parser[Any, object], Pattern[str], str, None] = None @classmethod def __prepare__( @@ -108,7 +108,7 @@ def __prepare__( bases: tuple[type, ...], /, *, - whitespace: Union[Parser[Any, Any], Pattern[str], str, None] = missing, + whitespace: Union[Parser[Any, object], Pattern[str], str, None] = missing, **kwargs: Any, ) -> ParsersDict: super().__prepare__(name, bases, **kwargs) diff --git a/src/parsita/parsers/_alternative.py b/src/parsita/parsers/_alternative.py index 98a053d..6716a3b 100644 --- a/src/parsita/parsers/_alternative.py +++ b/src/parsita/parsers/_alternative.py @@ -32,8 +32,8 @@ def first( parser: Union[Parser[Input, Output], Sequence[Input]], *parsers: Union[Parser[Input, Output], Sequence[Input]], ) -> FirstAlternativeParser[Input, Sequence[Input]]: - # This signature is not quite right because Python cannot express that - # Output must be a supertype of Sequence[Input]. + # This signature is not quite right because Python has no higher-kinded + # types to express that Output must be a subtype of Sequence[Input]. ... @@ -97,8 +97,8 @@ def longest( parser: Union[Parser[Input, Output], Sequence[Input]], *parsers: Union[Parser[Input, Output], Sequence[Input]], ) -> LongestAlternativeParser[Input, Sequence[Input]]: - # This signature is not quite right because Python cannot express that - # Output must be a supertype of Sequence[Input]. + # This signature is not quite right because Python has no higher-kinded + # types to express that Output must be a subtype of Sequence[Input]. ... diff --git a/src/parsita/parsers/_literal.py b/src/parsita/parsers/_literal.py index 2afe7cf..860d86f 100644 --- a/src/parsita/parsers/_literal.py +++ b/src/parsita/parsers/_literal.py @@ -70,7 +70,7 @@ def lit( ) -> Parser[Element, object]: """Match a literal sequence. - This parser returns successfully if the subsequence of the parsing Element + This parser returns successfully if the subsequence of the parsing input matches the literal sequence provided. If multiple literals are provided, they are treated as alternatives. e.g. diff --git a/src/parsita/parsers/_regex.py b/src/parsita/parsers/_regex.py index cc0f11a..d27b422 100644 --- a/src/parsita/parsers/_regex.py +++ b/src/parsita/parsers/_regex.py @@ -10,7 +10,7 @@ StringType = TypeVar("StringType", str, bytes) -# The Element type is str for str and int for bytes, but there is not way to +# The Element type is str for str and int for bytes, but there is no way to # express that in Python. class RegexParser(Generic[StringType], Parser[Any, StringType]): def __init__( diff --git a/tests/test_state.py b/tests/test_state.py index 9d25211..01ecb21 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -97,8 +97,8 @@ def test_isinstance(): def test_isinstance_result(): success = Success(1) failure = Failure(ParseError(StringReader("bar baz", 4), ["foo"])) - assert isinstance(success, Result) # type: ignore - assert isinstance(failure, Result) # type: ignore + assert isinstance(success, Result) + assert isinstance(failure, Result) def test_result_annotation():