1
1
from _typeshed import Incomplete
2
2
from collections .abc import Callable , Iterator , Sequence
3
3
from re import Match
4
- from typing import Any , NoReturn , TypeVar
4
+ from typing import Any , Generic , TypeVar
5
5
6
6
from parsimonious .exceptions import VisitationError as VisitationError
7
7
from parsimonious .expressions import Expression
@@ -27,14 +27,17 @@ class RegexNode(Node):
27
27
28
28
class RuleDecoratorMeta (type ): ...
29
29
30
- class NodeVisitor (metaclass = RuleDecoratorMeta ):
30
+ _VisitResultT = TypeVar ("_VisitResultT" )
31
+ _ChildT = TypeVar ("_ChildT" )
32
+
33
+ class NodeVisitor (Generic [_VisitResultT ], metaclass = RuleDecoratorMeta ):
31
34
grammar : Grammar | Incomplete
32
35
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 : ...
38
41
39
42
_CallableT = TypeVar ("_CallableT" , bound = Callable [..., Any ])
40
43
0 commit comments