massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / ast.pyi
1 # Rename typing to _typing, as not to conflict with typing imported
2 # from _ast below when loaded in an unorthodox way by the Dropbox
3 # internal Bazel integration.
4
5 # The same unorthodox Bazel integration causes issues with sys, which
6 # is imported in both modules. unfortunately we can't just rename sys,
7 # since mypy only supports version checks with a sys that is named
8 # sys.
9 import sys
10 import typing as _typing
11 from _ast import *  # type: ignore
12 from typing import Any, Iterator, TypeVar, overload
13 from typing_extensions import Literal
14
15 if sys.version_info >= (3, 8):
16     class Num(Constant):
17         value: complex
18     class Str(Constant):
19         value: str
20         # Aliases for value, for backwards compatibility
21         s: str
22     class Bytes(Constant):
23         value: bytes
24         # Aliases for value, for backwards compatibility
25         s: bytes
26     class NameConstant(Constant): ...
27     class Ellipsis(Constant): ...
28
29 if sys.version_info >= (3, 9):
30     class slice(AST): ...
31     class ExtSlice(slice): ...
32     class Index(slice): ...
33     class Suite(mod): ...
34     class AugLoad(expr_context): ...
35     class AugStore(expr_context): ...
36     class Param(expr_context): ...
37
38 class NodeVisitor:
39     def visit(self, node: AST) -> Any: ...
40     def generic_visit(self, node: AST) -> Any: ...
41     def visit_Module(self, node: Module) -> Any: ...
42     def visit_Interactive(self, node: Interactive) -> Any: ...
43     def visit_Expression(self, node: Expression) -> Any: ...
44     def visit_FunctionDef(self, node: FunctionDef) -> Any: ...
45     def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> Any: ...
46     def visit_ClassDef(self, node: ClassDef) -> Any: ...
47     def visit_Return(self, node: Return) -> Any: ...
48     def visit_Delete(self, node: Delete) -> Any: ...
49     def visit_Assign(self, node: Assign) -> Any: ...
50     def visit_AugAssign(self, node: AugAssign) -> Any: ...
51     def visit_AnnAssign(self, node: AnnAssign) -> Any: ...
52     def visit_For(self, node: For) -> Any: ...
53     def visit_AsyncFor(self, node: AsyncFor) -> Any: ...
54     def visit_While(self, node: While) -> Any: ...
55     def visit_If(self, node: If) -> Any: ...
56     def visit_With(self, node: With) -> Any: ...
57     def visit_AsyncWith(self, node: AsyncWith) -> Any: ...
58     def visit_Raise(self, node: Raise) -> Any: ...
59     def visit_Try(self, node: Try) -> Any: ...
60     def visit_Assert(self, node: Assert) -> Any: ...
61     def visit_Import(self, node: Import) -> Any: ...
62     def visit_ImportFrom(self, node: ImportFrom) -> Any: ...
63     def visit_Global(self, node: Global) -> Any: ...
64     def visit_Nonlocal(self, node: Nonlocal) -> Any: ...
65     def visit_Expr(self, node: Expr) -> Any: ...
66     def visit_Pass(self, node: Pass) -> Any: ...
67     def visit_Break(self, node: Break) -> Any: ...
68     def visit_Continue(self, node: Continue) -> Any: ...
69     def visit_Slice(self, node: Slice) -> Any: ...
70     def visit_BoolOp(self, node: BoolOp) -> Any: ...
71     def visit_BinOp(self, node: BinOp) -> Any: ...
72     def visit_UnaryOp(self, node: UnaryOp) -> Any: ...
73     def visit_Lambda(self, node: Lambda) -> Any: ...
74     def visit_IfExp(self, node: IfExp) -> Any: ...
75     def visit_Dict(self, node: Dict) -> Any: ...
76     def visit_Set(self, node: Set) -> Any: ...
77     def visit_ListComp(self, node: ListComp) -> Any: ...
78     def visit_SetComp(self, node: SetComp) -> Any: ...
79     def visit_DictComp(self, node: DictComp) -> Any: ...
80     def visit_GeneratorExp(self, node: GeneratorExp) -> Any: ...
81     def visit_Await(self, node: Await) -> Any: ...
82     def visit_Yield(self, node: Yield) -> Any: ...
83     def visit_YieldFrom(self, node: YieldFrom) -> Any: ...
84     def visit_Compare(self, node: Compare) -> Any: ...
85     def visit_Call(self, node: Call) -> Any: ...
86     def visit_FormattedValue(self, node: FormattedValue) -> Any: ...
87     def visit_JoinedStr(self, node: JoinedStr) -> Any: ...
88     def visit_Constant(self, node: Constant) -> Any: ...
89     if sys.version_info >= (3, 8):
90         def visit_NamedExpr(self, node: NamedExpr) -> Any: ...
91     def visit_Attribute(self, node: Attribute) -> Any: ...
92     def visit_Subscript(self, node: Subscript) -> Any: ...
93     def visit_Starred(self, node: Starred) -> Any: ...
94     def visit_Name(self, node: Name) -> Any: ...
95     def visit_List(self, node: List) -> Any: ...
96     def visit_Tuple(self, node: Tuple) -> Any: ...
97     def visit_Del(self, node: Del) -> Any: ...
98     def visit_Load(self, node: Load) -> Any: ...
99     def visit_Store(self, node: Store) -> Any: ...
100     def visit_And(self, node: And) -> Any: ...
101     def visit_Or(self, node: Or) -> Any: ...
102     def visit_Add(self, node: Add) -> Any: ...
103     def visit_BitAnd(self, node: BitAnd) -> Any: ...
104     def visit_BitOr(self, node: BitOr) -> Any: ...
105     def visit_BitXor(self, node: BitXor) -> Any: ...
106     def visit_Div(self, node: Div) -> Any: ...
107     def visit_FloorDiv(self, node: FloorDiv) -> Any: ...
108     def visit_LShift(self, node: LShift) -> Any: ...
109     def visit_Mod(self, node: Mod) -> Any: ...
110     def visit_Mult(self, node: Mult) -> Any: ...
111     def visit_MatMult(self, node: MatMult) -> Any: ...
112     def visit_Pow(self, node: Pow) -> Any: ...
113     def visit_RShift(self, node: RShift) -> Any: ...
114     def visit_Sub(self, node: Sub) -> Any: ...
115     def visit_Invert(self, node: Invert) -> Any: ...
116     def visit_Not(self, node: Not) -> Any: ...
117     def visit_UAdd(self, node: UAdd) -> Any: ...
118     def visit_USub(self, node: USub) -> Any: ...
119     def visit_Eq(self, node: Eq) -> Any: ...
120     def visit_Gt(self, node: Gt) -> Any: ...
121     def visit_GtE(self, node: GtE) -> Any: ...
122     def visit_In(self, node: In) -> Any: ...
123     def visit_Is(self, node: Is) -> Any: ...
124     def visit_IsNot(self, node: IsNot) -> Any: ...
125     def visit_Lt(self, node: Lt) -> Any: ...
126     def visit_LtE(self, node: LtE) -> Any: ...
127     def visit_NotEq(self, node: NotEq) -> Any: ...
128     def visit_NotIn(self, node: NotIn) -> Any: ...
129     def visit_comprehension(self, node: comprehension) -> Any: ...
130     def visit_ExceptHandler(self, node: ExceptHandler) -> Any: ...
131     def visit_arguments(self, node: arguments) -> Any: ...
132     def visit_arg(self, node: arg) -> Any: ...
133     def visit_keyword(self, node: keyword) -> Any: ...
134     def visit_alias(self, node: alias) -> Any: ...
135     def visit_withitem(self, node: withitem) -> Any: ...
136     # visit methods for deprecated nodes
137     def visit_ExtSlice(self, node: ExtSlice) -> Any: ...
138     def visit_Index(self, node: Index) -> Any: ...
139     def visit_Suite(self, node: Suite) -> Any: ...
140     def visit_AugLoad(self, node: AugLoad) -> Any: ...
141     def visit_AugStore(self, node: AugStore) -> Any: ...
142     def visit_Param(self, node: Param) -> Any: ...
143     def visit_Num(self, node: Num) -> Any: ...
144     def visit_Str(self, node: Str) -> Any: ...
145     def visit_Bytes(self, node: Bytes) -> Any: ...
146     def visit_NameConstant(self, node: NameConstant) -> Any: ...
147     def visit_Ellipsis(self, node: Ellipsis) -> Any: ...
148
149 class NodeTransformer(NodeVisitor):
150     def generic_visit(self, node: AST) -> AST: ...
151     # TODO: Override the visit_* methods with better return types.
152     #       The usual return type is AST | None, but Iterable[AST]
153     #       is also allowed in some cases -- this needs to be mapped.
154
155 _T = TypeVar("_T", bound=AST)
156
157 if sys.version_info >= (3, 8):
158     @overload
159     def parse(
160         source: str | bytes,
161         filename: str | bytes = ...,
162         mode: Literal["exec"] = ...,
163         *,
164         type_comments: bool = ...,
165         feature_version: None | int | _typing.Tuple[int, int] = ...,
166     ) -> Module: ...
167     @overload
168     def parse(
169         source: str | bytes,
170         filename: str | bytes = ...,
171         mode: str = ...,
172         *,
173         type_comments: bool = ...,
174         feature_version: None | int | _typing.Tuple[int, int] = ...,
175     ) -> AST: ...
176
177 else:
178     @overload
179     def parse(source: str | bytes, filename: str | bytes = ..., mode: Literal["exec"] = ...) -> Module: ...
180     @overload
181     def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ...
182
183 if sys.version_info >= (3, 9):
184     def unparse(ast_obj: AST) -> str: ...
185
186 def copy_location(new_node: _T, old_node: AST) -> _T: ...
187
188 if sys.version_info >= (3, 9):
189     def dump(
190         node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: int | str | None = ...
191     ) -> str: ...
192
193 else:
194     def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
195
196 def fix_missing_locations(node: _T) -> _T: ...
197 def get_docstring(node: AST, clean: bool = ...) -> str | None: ...
198 def increment_lineno(node: _T, n: int = ...) -> _T: ...
199 def iter_child_nodes(node: AST) -> Iterator[AST]: ...
200 def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ...
201 def literal_eval(node_or_string: str | AST) -> Any: ...
202
203 if sys.version_info >= (3, 8):
204     def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ...
205
206 def walk(node: AST) -> Iterator[AST]: ...