Skip to content

Commit

Permalink
Additional fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
drhagen committed Nov 20, 2024
1 parent 7a18368 commit 4eabfcf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/parsita/metaclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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__(
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/parsita/parsers/_alternative.py
Original file line number Diff line number Diff line change
Expand Up @@ -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].
...


Expand Down Expand Up @@ -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].
...


Expand Down
2 changes: 1 addition & 1 deletion src/parsita/parsers/_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/parsita/parsers/_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 4eabfcf

Please sign in to comment.