-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path_ast.pyi
More file actions
412 lines (338 loc) · 8.25 KB
/
_ast.pyi
File metadata and controls
412 lines (338 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
import sys
import typing
from typing import Any, ClassVar
from typing_extensions import Literal
PyCF_ONLY_AST: int
if sys.version_info >= (3, 8):
PyCF_TYPE_COMMENTS: int
PyCF_ALLOW_TOP_LEVEL_AWAIT: int
_identifier = str
class AST:
_attributes: ClassVar[typing.Tuple[str, ...]]
_fields: ClassVar[typing.Tuple[str, ...]]
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
# TODO: Not all nodes have all of the following attributes
lineno: int
col_offset: int
if sys.version_info >= (3, 8):
end_lineno: int | None
end_col_offset: int | None
type_comment: str | None
class mod(AST): ...
if sys.version_info >= (3, 8):
class type_ignore(AST): ...
class TypeIgnore(type_ignore):
tag: str
class FunctionType(mod):
argtypes: list[expr]
returns: expr
class Module(mod):
body: list[stmt]
if sys.version_info >= (3, 8):
type_ignores: list[TypeIgnore]
class Interactive(mod):
body: list[stmt]
class Expression(mod):
body: expr
class stmt(AST): ...
class FunctionDef(stmt):
name: _identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
class AsyncFunctionDef(stmt):
name: _identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
class ClassDef(stmt):
name: _identifier
bases: list[expr]
keywords: list[keyword]
body: list[stmt]
decorator_list: list[expr]
class Return(stmt):
value: expr | None
class Delete(stmt):
targets: list[expr]
class Assign(stmt):
targets: list[expr]
value: expr
class AugAssign(stmt):
target: expr
op: operator
value: expr
class AnnAssign(stmt):
target: expr
annotation: expr
value: expr | None
simple: int
class For(stmt):
target: expr
iter: expr
body: list[stmt]
orelse: list[stmt]
class AsyncFor(stmt):
target: expr
iter: expr
body: list[stmt]
orelse: list[stmt]
class While(stmt):
test: expr
body: list[stmt]
orelse: list[stmt]
class If(stmt):
test: expr
body: list[stmt]
orelse: list[stmt]
class With(stmt):
items: list[withitem]
body: list[stmt]
class AsyncWith(stmt):
items: list[withitem]
body: list[stmt]
class Raise(stmt):
exc: expr | None
cause: expr | None
class Try(stmt):
body: list[stmt]
handlers: list[ExceptHandler]
orelse: list[stmt]
finalbody: list[stmt]
class Assert(stmt):
test: expr
msg: expr | None
class Import(stmt):
names: list[alias]
class ImportFrom(stmt):
module: _identifier | None
names: list[alias]
level: int
class Global(stmt):
names: list[_identifier]
class Nonlocal(stmt):
names: list[_identifier]
class Expr(stmt):
value: expr
class Pass(stmt): ...
class Break(stmt): ...
class Continue(stmt): ...
class expr(AST): ...
class BoolOp(expr):
op: boolop
values: list[expr]
class BinOp(expr):
left: expr
op: operator
right: expr
class UnaryOp(expr):
op: unaryop
operand: expr
class Lambda(expr):
args: arguments
body: expr
class IfExp(expr):
test: expr
body: expr
orelse: expr
class Dict(expr):
keys: list[expr | None]
values: list[expr]
class Set(expr):
elts: list[expr]
class ListComp(expr):
elt: expr
generators: list[comprehension]
class SetComp(expr):
elt: expr
generators: list[comprehension]
class DictComp(expr):
key: expr
value: expr
generators: list[comprehension]
class GeneratorExp(expr):
elt: expr
generators: list[comprehension]
class Await(expr):
value: expr
class Yield(expr):
value: expr | None
class YieldFrom(expr):
value: expr
class Compare(expr):
left: expr
ops: list[cmpop]
comparators: list[expr]
class Call(expr):
func: expr
args: list[expr]
keywords: list[keyword]
class FormattedValue(expr):
value: expr
conversion: int | None
format_spec: expr | None
class JoinedStr(expr):
values: list[expr]
if sys.version_info < (3, 8):
class Num(expr): # Deprecated in 3.8; use Constant
n: complex
class Str(expr): # Deprecated in 3.8; use Constant
s: str
class Bytes(expr): # Deprecated in 3.8; use Constant
s: bytes
class NameConstant(expr): # Deprecated in 3.8; use Constant
value: Any
class Ellipsis(expr): ... # Deprecated in 3.8; use Constant
class Constant(expr):
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
kind: str | None
# Aliases for value, for backwards compatibility
s: Any
n: complex
if sys.version_info >= (3, 8):
class NamedExpr(expr):
target: expr
value: expr
class Attribute(expr):
value: expr
attr: _identifier
ctx: expr_context
if sys.version_info >= (3, 9):
_SliceT = expr
else:
class slice(AST): ...
_SliceT = slice
class Slice(_SliceT):
lower: expr | None
upper: expr | None
step: expr | None
if sys.version_info < (3, 9):
class ExtSlice(slice):
dims: list[slice]
class Index(slice):
value: expr
class Subscript(expr):
value: expr
slice: _SliceT
ctx: expr_context
class Starred(expr):
value: expr
ctx: expr_context
class Name(expr):
id: _identifier
ctx: expr_context
class List(expr):
elts: list[expr]
ctx: expr_context
class Tuple(expr):
elts: list[expr]
ctx: expr_context
class expr_context(AST): ...
if sys.version_info < (3, 9):
class AugLoad(expr_context): ...
class AugStore(expr_context): ...
class Param(expr_context): ...
class Suite(mod):
body: list[stmt]
class Del(expr_context): ...
class Load(expr_context): ...
class Store(expr_context): ...
class boolop(AST): ...
class And(boolop): ...
class Or(boolop): ...
class operator(AST): ...
class Add(operator): ...
class BitAnd(operator): ...
class BitOr(operator): ...
class BitXor(operator): ...
class Div(operator): ...
class FloorDiv(operator): ...
class LShift(operator): ...
class Mod(operator): ...
class Mult(operator): ...
class MatMult(operator): ...
class Pow(operator): ...
class RShift(operator): ...
class Sub(operator): ...
class unaryop(AST): ...
class Invert(unaryop): ...
class Not(unaryop): ...
class UAdd(unaryop): ...
class USub(unaryop): ...
class cmpop(AST): ...
class Eq(cmpop): ...
class Gt(cmpop): ...
class GtE(cmpop): ...
class In(cmpop): ...
class Is(cmpop): ...
class IsNot(cmpop): ...
class Lt(cmpop): ...
class LtE(cmpop): ...
class NotEq(cmpop): ...
class NotIn(cmpop): ...
class comprehension(AST):
target: expr
iter: expr
ifs: list[expr]
is_async: int
class excepthandler(AST): ...
class ExceptHandler(excepthandler):
type: expr | None
name: _identifier | None
body: list[stmt]
class arguments(AST):
if sys.version_info >= (3, 8):
posonlyargs: list[arg]
args: list[arg]
vararg: arg | None
kwonlyargs: list[arg]
kw_defaults: list[expr | None]
kwarg: arg | None
defaults: list[expr]
class arg(AST):
arg: _identifier
annotation: expr | None
class keyword(AST):
arg: _identifier | None
value: expr
class alias(AST):
name: _identifier
asname: _identifier | None
class withitem(AST):
context_expr: expr
optional_vars: expr | None
if sys.version_info >= (3, 10):
class Match(stmt):
subject: expr
cases: list[match_case]
class pattern(AST): ...
# Without the alias, Pyright complains variables named pattern are recursively defined
_pattern = pattern
class match_case(AST):
pattern: _pattern
guard: expr | None
body: list[stmt]
class MatchValue(pattern):
value: expr
class MatchSingleton(pattern):
value: Literal[True, False, None]
class MatchSequence(pattern):
patterns: list[pattern]
class MatchStar(pattern):
name: _identifier | None
class MatchMapping(pattern):
keys: list[expr]
patterns: list[pattern]
rest: _identifier | None
class MatchClass(pattern):
cls: expr
patterns: list[pattern]
kwd_attrs: list[_identifier]
kwd_patterns: list[pattern]
class MatchAs(pattern):
pattern: _pattern | None
name: _identifier | None
class MatchOr(pattern):
patterns: list[pattern]