11from _typeshed import Incomplete
22from collections .abc import Callable , Iterator , Sequence
33from re import Match
4- from typing import Any , NoReturn , TypeVar
4+ from typing import Any , Generic , TypeVar
55
66from parsimonious .exceptions import VisitationError as VisitationError
77from parsimonious .expressions import Expression
@@ -27,14 +27,17 @@ class RegexNode(Node):
2727
2828class RuleDecoratorMeta (type ): ...
2929
30- class NodeVisitor (metaclass = RuleDecoratorMeta ):
30+ _VisitResultT = TypeVar ("_VisitResultT" )
31+ _ChildT = TypeVar ("_ChildT" )
32+
33+ class NodeVisitor (Generic [_VisitResultT ], metaclass = RuleDecoratorMeta ):
3134 grammar : Grammar | Incomplete
3235 unwrapped_exceptions : tuple [type [BaseException ], ...]
33- def visit (self , node : Node ) -> Any : ...
34- def generic_visit (self , node : Node , visited_children : Sequence [Any ]) -> NoReturn : ...
35- def parse (self , text : str , pos : int = ...) -> Node : ...
36- def match (self , text : str , pos : int = ...) -> Node : ...
37- def lift_child (self , node : Node , children : Sequence [Any ]) -> Any : ...
36+ def visit (self , node : Node ) -> _VisitResultT : ...
37+ def generic_visit (self , node : Node , visited_children : Sequence [Any ]) -> Incomplete : ...
38+ def parse (self , text : str , pos : int = ...) -> _VisitResultT : ...
39+ def match (self , text : str , pos : int = ...) -> _VisitResultT : ...
40+ def lift_child (self , node : Node , children : Sequence [_ChildT ]) -> _ChildT : ...
3841
3942_CallableT = TypeVar ("_CallableT" , bound = Callable [..., Any ])
4043
0 commit comments