massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / lib2to3 / pytree.pyi
1 from lib2to3.pgen2.grammar import Grammar
2 from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union
3
4 _P = TypeVar("_P")
5 _NL = Union[Node, Leaf]
6 _Context = Tuple[str, int, int]
7 _Results = Dict[str, _NL]
8 _RawNode = Tuple[int, str, _Context, Optional[List[_NL]]]
9 _Convert = Callable[[Grammar, _RawNode], Any]
10
11 HUGE: int
12
13 def type_repr(type_num: int) -> str: ...
14
15 class Base:
16     type: int
17     parent: Node | None
18     prefix: str
19     children: list[_NL]
20     was_changed: bool
21     was_checked: bool
22     def __eq__(self, other: Any) -> bool: ...
23     def _eq(self: _P, other: _P) -> bool: ...
24     def clone(self: _P) -> _P: ...
25     def post_order(self) -> Iterator[_NL]: ...
26     def pre_order(self) -> Iterator[_NL]: ...
27     def replace(self, new: _NL | list[_NL]) -> None: ...
28     def get_lineno(self) -> int: ...
29     def changed(self) -> None: ...
30     def remove(self) -> int | None: ...
31     @property
32     def next_sibling(self) -> _NL | None: ...
33     @property
34     def prev_sibling(self) -> _NL | None: ...
35     def leaves(self) -> Iterator[Leaf]: ...
36     def depth(self) -> int: ...
37     def get_suffix(self) -> str: ...
38
39 class Node(Base):
40     fixers_applied: list[Any]
41     def __init__(
42         self,
43         type: int,
44         children: list[_NL],
45         context: Any | None = ...,
46         prefix: str | None = ...,
47         fixers_applied: list[Any] | None = ...,
48     ) -> None: ...
49     def set_child(self, i: int, child: _NL) -> None: ...
50     def insert_child(self, i: int, child: _NL) -> None: ...
51     def append_child(self, child: _NL) -> None: ...
52
53 class Leaf(Base):
54     lineno: int
55     column: int
56     value: str
57     fixers_applied: list[Any]
58     def __init__(
59         self, type: int, value: str, context: _Context | None = ..., prefix: str | None = ..., fixers_applied: list[Any] = ...
60     ) -> None: ...
61
62 def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ...
63
64 class BasePattern:
65     type: int
66     content: str | None
67     name: str | None
68     def optimize(self) -> BasePattern: ...  # sic, subclasses are free to optimize themselves into different patterns
69     def match(self, node: _NL, results: _Results | None = ...) -> bool: ...
70     def match_seq(self, nodes: list[_NL], results: _Results | None = ...) -> bool: ...
71     def generate_matches(self, nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ...
72
73 class LeafPattern(BasePattern):
74     def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ...
75
76 class NodePattern(BasePattern):
77     wildcards: bool
78     def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ...
79
80 class WildcardPattern(BasePattern):
81     min: int
82     max: int
83     def __init__(self, content: str | None = ..., min: int = ..., max: int = ..., name: str | None = ...) -> None: ...
84
85 class NegatedPattern(BasePattern):
86     def __init__(self, content: str | None = ...) -> None: ...
87
88 def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ...