From 7a1836841db61f8e166dc187228cc4719b7b369c Mon Sep 17 00:00:00 2001 From: David Hagen Date: Wed, 20 Nov 2024 05:52:32 -0500 Subject: [PATCH] Change pass to ... in overloaded definitions --- src/parsita/metaclasses.py | 3 +- src/parsita/parsers/_alternative.py | 10 +++--- src/parsita/parsers/_base.py | 42 ++++++++-------------- src/parsita/parsers/_debug.py | 6 ++-- src/parsita/parsers/_literal.py | 9 ++--- src/parsita/parsers/_optional.py | 6 ++-- src/parsita/parsers/_repeated.py | 12 +++---- src/parsita/parsers/_repeated_seperated.py | 12 +++---- src/parsita/state/_reader.py | 15 +++----- 9 files changed, 39 insertions(+), 76 deletions(-) diff --git a/src/parsita/metaclasses.py b/src/parsita/metaclasses.py index d2ad881..3e9b516 100644 --- a/src/parsita/metaclasses.py +++ b/src/parsita/metaclasses.py @@ -82,8 +82,7 @@ def __getattribute__(self, member: str) -> Any: def _consume( self, state: State, reader: Reader[Input] - ) -> Optional[Continue[Input, Output]]: - pass + ) -> Optional[Continue[Input, Output]]: ... def define(self, parser: Parser[Input, Output]) -> None: self._definition = parser diff --git a/src/parsita/parsers/_alternative.py b/src/parsita/parsers/_alternative.py index 6022c79..98a053d 100644 --- a/src/parsita/parsers/_alternative.py +++ b/src/parsita/parsers/_alternative.py @@ -34,15 +34,14 @@ def first( ) -> FirstAlternativeParser[Input, Sequence[Input]]: # This signature is not quite right because Python cannot express that # Output must be a supertype of Sequence[Input]. - pass + ... @overload def first( parser: Parser[Input, Output], *parsers: Parser[Input, Output], -) -> FirstAlternativeParser[Input, Output]: - pass +) -> FirstAlternativeParser[Input, Output]: ... def first( @@ -100,15 +99,14 @@ def longest( ) -> LongestAlternativeParser[Input, Sequence[Input]]: # This signature is not quite right because Python cannot express that # Output must be a supertype of Sequence[Input]. - pass + ... @overload def longest( parser: Parser[Input, Output], *parsers: Parser[Input, Output], -) -> LongestAlternativeParser[Input, Output]: - pass +) -> LongestAlternativeParser[Input, Output]: ... def longest( diff --git a/src/parsita/parsers/_base.py b/src/parsita/parsers/_base.py index bc7ee80..d8efce7 100644 --- a/src/parsita/parsers/_base.py +++ b/src/parsita/parsers/_base.py @@ -28,13 +28,11 @@ @overload -def wrap_literal(obj: Sequence[Input]) -> Parser[Input, Sequence[Input]]: - pass +def wrap_literal(obj: Sequence[Input]) -> Parser[Input, Sequence[Input]]: ... @overload -def wrap_literal(obj: Parser[Input, Output]) -> Parser[Input, Output]: - pass +def wrap_literal(obj: Parser[Input, Output]) -> Parser[Input, Output]: ... def wrap_literal( @@ -198,14 +196,12 @@ def name_or_nothing(self) -> str: return self.name + " = " @overload - def __or__(self, other: Sequence[Input]) -> Parser[Input, Union[Output, Sequence[Input]]]: - pass + def __or__(self, other: Sequence[Input]) -> Parser[Input, Union[Output, Sequence[Input]]]: ... @overload def __or__( self, other: Parser[Input, OtherOutput] - ) -> Parser[Input, Union[Output, OtherOutput]]: - pass + ) -> Parser[Input, Union[Output, OtherOutput]]: ... def __or__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] @@ -225,14 +221,12 @@ def __or__( return LongestAlternativeParser(*parsers) @overload - def __ror__(self, other: Sequence[Input]) -> Parser[Input, Union[Sequence[Input], Output]]: - pass + def __ror__(self, other: Sequence[Input]) -> Parser[Input, Union[Sequence[Input], Output]]: ... @overload def __ror__( self, other: Parser[Input, OtherOutput] - ) -> Parser[Input, Union[OtherOutput, Output]]: - pass + ) -> Parser[Input, Union[OtherOutput, Output]]: ... def __ror__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] @@ -241,12 +235,10 @@ def __ror__( return narrowed_other.__or__(self) @overload - def __and__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Any]]: - pass + def __and__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Any]]: ... @overload - def __and__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, Sequence[Any]]: - pass + def __and__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, Sequence[Any]]: ... def __and__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] @@ -260,12 +252,10 @@ def __and__( return SequentialParser(self, narrowed_other) @overload - def __rand__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Any]]: - pass + def __rand__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Any]]: ... @overload - def __rand__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, Sequence[Any]]: - pass + def __rand__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, Sequence[Any]]: ... def __rand__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] @@ -274,12 +264,10 @@ def __rand__( return narrowed_other.__and__(self) @overload - def __rshift__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Input]]: - pass + def __rshift__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Input]]: ... @overload - def __rshift__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, OtherOutput]: - pass + def __rshift__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, OtherOutput]: ... def __rshift__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] @@ -304,12 +292,10 @@ def __lshift__( return DiscardRightParser(self, narrowed_other) @overload - def __rlshift__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Input]]: - pass + def __rlshift__(self, other: Sequence[Input]) -> Parser[Input, Sequence[Input]]: ... @overload - def __rlshift__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, OtherOutput]: - pass + def __rlshift__(self, other: Parser[Input, OtherOutput]) -> Parser[Input, OtherOutput]: ... def __rlshift__( self, other: Union[Sequence[Input], Parser[Input, OtherOutput]] diff --git a/src/parsita/parsers/_debug.py b/src/parsita/parsers/_debug.py index b3a46f0..4af1148 100644 --- a/src/parsita/parsers/_debug.py +++ b/src/parsita/parsers/_debug.py @@ -43,8 +43,7 @@ def debug( *, verbose: bool = False, callback: Optional[Callable[[Parser[Input, Sequence[Input]], Reader[Input]], None]] = None, -) -> DebugParser[Input, Sequence[Input]]: - pass +) -> DebugParser[Input, Sequence[Input]]: ... @overload @@ -53,8 +52,7 @@ def debug( *, verbose: bool = False, callback: Optional[Callable[[Parser[Input, Output], Reader[Input]], None]] = None, -) -> DebugParser[Input, Output]: - pass +) -> DebugParser[Input, Output]: ... def debug( diff --git a/src/parsita/parsers/_literal.py b/src/parsita/parsers/_literal.py index 1c1af32..2afe7cf 100644 --- a/src/parsita/parsers/_literal.py +++ b/src/parsita/parsers/_literal.py @@ -54,18 +54,15 @@ def __repr__(self) -> str: @overload -def lit(literal: str, *literals: str) -> Parser[str, str]: - pass +def lit(literal: str, *literals: str) -> Parser[str, str]: ... @overload -def lit(literal: bytes, *literals: bytes) -> Parser[int, bytes]: - pass +def lit(literal: bytes, *literals: bytes) -> Parser[int, bytes]: ... @overload -def lit(literal: FunctionLiteral, *literals: FunctionLiteral) -> Parser[Any, FunctionLiteral]: - pass +def lit(literal: FunctionLiteral, *literals: FunctionLiteral) -> Parser[Any, FunctionLiteral]: ... def lit( diff --git a/src/parsita/parsers/_optional.py b/src/parsita/parsers/_optional.py index 92975a5..3081561 100644 --- a/src/parsita/parsers/_optional.py +++ b/src/parsita/parsers/_optional.py @@ -26,15 +26,13 @@ def __repr__(self) -> str: @overload def opt( parser: Sequence[Input], -) -> OptionalParser[Input, Sequence[Input]]: - pass +) -> OptionalParser[Input, Sequence[Input]]: ... @overload def opt( parser: Parser[Input, Output], -) -> OptionalParser[Input, Output]: - pass +) -> OptionalParser[Input, Output]: ... def opt( diff --git a/src/parsita/parsers/_repeated.py b/src/parsita/parsers/_repeated.py index 7975a4d..0079ad4 100644 --- a/src/parsita/parsers/_repeated.py +++ b/src/parsita/parsers/_repeated.py @@ -37,13 +37,11 @@ def __repr__(self) -> str: @overload -def rep1(parser: Sequence[Input]) -> RepeatedOnceParser[Input, Sequence[Input]]: - pass +def rep1(parser: Sequence[Input]) -> RepeatedOnceParser[Input, Sequence[Input]]: ... @overload -def rep1(parser: Parser[Input, Output]) -> RepeatedOnceParser[Input, Output]: - pass +def rep1(parser: Parser[Input, Output]) -> RepeatedOnceParser[Input, Output]: ... def rep1( @@ -104,8 +102,7 @@ def rep( *, min: int = 0, max: Optional[int] = None, -) -> RepeatedParser[Input, Sequence[Input]]: - pass +) -> RepeatedParser[Input, Sequence[Input]]: ... @overload @@ -114,8 +111,7 @@ def rep( *, min: int = 0, max: Optional[int] = None, -) -> RepeatedParser[Input, Output]: - pass +) -> RepeatedParser[Input, Output]: ... def rep( diff --git a/src/parsita/parsers/_repeated_seperated.py b/src/parsita/parsers/_repeated_seperated.py index 1196d86..0a59965 100644 --- a/src/parsita/parsers/_repeated_seperated.py +++ b/src/parsita/parsers/_repeated_seperated.py @@ -73,8 +73,7 @@ def repsep( *, min: int = 0, max: Optional[int] = None, -) -> RepeatedSeparatedParser[Input, Sequence[Input]]: - pass +) -> RepeatedSeparatedParser[Input, Sequence[Input]]: ... @overload @@ -84,8 +83,7 @@ def repsep( *, min: int = 0, max: Optional[int] = None, -) -> RepeatedSeparatedParser[Input, Output]: - pass +) -> RepeatedSeparatedParser[Input, Output]: ... def repsep( @@ -157,15 +155,13 @@ def __repr__(self) -> str: @overload def rep1sep( parser: Sequence[Input], separator: Union[Parser[Input, object], Sequence[Input]] -) -> RepeatedOnceSeparatedParser[Input, Sequence[Input]]: - pass +) -> RepeatedOnceSeparatedParser[Input, Sequence[Input]]: ... @overload def rep1sep( parser: Parser[Input, Output], separator: Union[Parser[Input, object], Sequence[Input]] -) -> RepeatedOnceSeparatedParser[Input, Output]: - pass +) -> RepeatedOnceSeparatedParser[Input, Output]: ... def rep1sep( diff --git a/src/parsita/state/_reader.py b/src/parsita/state/_reader.py index fe645a1..c7c2ab5 100644 --- a/src/parsita/state/_reader.py +++ b/src/parsita/state/_reader.py @@ -30,24 +30,19 @@ class Reader(Generic[Input]): # dataclass subclasses @property - def first(self) -> Input: - pass + def first(self) -> Input: ... @property - def rest(self) -> Reader[Input]: - pass + def rest(self) -> Reader[Input]: ... @property - def position(self) -> int: - pass + def position(self) -> int: ... @property - def finished(self) -> bool: - pass + def finished(self) -> bool: ... @property - def source(self) -> Sequence[Input]: - pass + def source(self) -> Sequence[Input]: ... def drop(self, count: int) -> Reader[Input]: """Advance the reader by ``count`` elements.