parsimonious: Update return types of NodeVisitor's methods (#9564)

This commit is contained in:
Oleh Mazur authored and GitHub committed 2023-03-08 22:05:34 -08:00
1 parent f8add366d5
commit 8ff3278ef7
2 files changed
+11 -8

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ class LazyReference(str):
name: str
def resolve_refs(self, rule_map: Mapping[str, Expression | LazyReference]) -> Expression: ...
class RuleVisitor(NodeVisitor):
class RuleVisitor(NodeVisitor[tuple[OrderedDict[str, Expression], Expression | None]]):
quantifier_classes: dict[str, type[Expression]]
visit_expression: Callable[[RuleVisitor, Node, collections.abc.Sequence[Any]], Any]
visit_term: Callable[[RuleVisitor, Node, collections.abc.Sequence[Any]], Any]
+10 -7
View File
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterator, Sequence
from re import Match
from typing import Any, NoReturn, TypeVar
from typing import Any, Generic, TypeVar
from parsimonious.exceptions import VisitationError as VisitationError
from parsimonious.expressions import Expression
@@ -27,14 +27,17 @@ class RegexNode(Node):
class RuleDecoratorMeta(type): ...
class NodeVisitor(metaclass=RuleDecoratorMeta):
_VisitResultT = TypeVar("_VisitResultT")
_ChildT = TypeVar("_ChildT")
class NodeVisitor(Generic[_VisitResultT], metaclass=RuleDecoratorMeta):
grammar: Grammar | Incomplete
unwrapped_exceptions: tuple[type[BaseException], ...]
def visit(self, node: Node) -> Any: ...
def generic_visit(self, node: Node, visited_children: Sequence[Any]) -> NoReturn: ...
def parse(self, text: str, pos: int = ...) -> Node: ...
def match(self, text: str, pos: int = ...) -> Node: ...
def lift_child(self, node: Node, children: Sequence[Any]) -> Any: ...
def visit(self, node: Node) -> _VisitResultT: ...
def generic_visit(self, node: Node, visited_children: Sequence[Any]) -> Incomplete: ...
def parse(self, text: str, pos: int = ...) -> _VisitResultT: ...
def match(self, text: str, pos: int = ...) -> _VisitResultT: ...
def lift_child(self, node: Node, children: Sequence[_ChildT]) -> _ChildT: ...
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])