mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
parsimonious: Update return types of NodeVisitor's methods (#9564)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user