Debian Codegraph @

jedi/third_party/typeshed/stdlib/ast.pyi

raw symbols SCIP
1 import ast
2 import builtins
3 import os
4 import sys
5 import typing_extensions
6 from _ast import (
7 PyCF_ALLOW_TOP_LEVEL_AWAIT as PyCF_ALLOW_TOP_LEVEL_AWAIT,
8 PyCF_ONLY_AST as PyCF_ONLY_AST,
9 PyCF_TYPE_COMMENTS as PyCF_TYPE_COMMENTS,
10 )
11 from _typeshed import ReadableBuffer, Unused
12 from collections.abc import Iterable, Iterator, Sequence
13 from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload, type_check_only
14 from typing_extensions import Self, Unpack, deprecated, disjoint_base
15
16 if sys.version_info >= (3, 13):
17 from _ast import PyCF_OPTIMIZED_AST as PyCF_OPTIMIZED_AST
18
19 # Used for node end positions in constructor keyword arguments
20 _EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None)
21
22 # Corresponds to the names in the `_attributes` class variable which is non-empty in certain AST nodes
23 @type_check_only
24 class _Attributes(TypedDict, Generic[_EndPositionT], total=False):
25 lineno: int
26 col_offset: int
27 end_lineno: _EndPositionT
28 end_col_offset: _EndPositionT
29
30 # The various AST classes are implemented in C, and imported from _ast at runtime,
31 # but they consider themselves to live in the ast module,
32 # so we'll define the stubs in this file.
33 if sys.version_info >= (3, 12):
34 @disjoint_base
35 class AST:
36 __match_args__ = ()
37 _attributes: ClassVar[tuple[str, ...]]
38 _fields: ClassVar[tuple[str, ...]]
39 if sys.version_info >= (3, 13):
40 _field_types: ClassVar[dict[str, Any]]
41
42 if sys.version_info >= (3, 14):
43 def __replace__(self) -> Self: ...
44
45 else:
46 class AST:
47 if sys.version_info >= (3, 10):
48 __match_args__ = ()
49 _attributes: ClassVar[tuple[str, ...]]
50 _fields: ClassVar[tuple[str, ...]]
51
52 class mod(AST): ...
53
54 class Module(mod):
55 if sys.version_info >= (3, 10):
56 __match_args__ = ("body", "type_ignores")
57 body: list[stmt]
58 type_ignores: list[TypeIgnore]
59 if sys.version_info >= (3, 13):
60 def __init__(self, body: list[stmt] = ..., type_ignores: list[TypeIgnore] = ...) -> None: ...
61 else:
62 def __init__(self, body: list[stmt], type_ignores: list[TypeIgnore]) -> None: ...
63
64 if sys.version_info >= (3, 14):
65 def __replace__(self, *, body: list[stmt] = ..., type_ignores: list[TypeIgnore] = ...) -> Self: ...
66
67 class Interactive(mod):
68 if sys.version_info >= (3, 10):
69 __match_args__ = ("body",)
70 body: list[stmt]
71 if sys.version_info >= (3, 13):
72 def __init__(self, body: list[stmt] = ...) -> None: ...
73 else:
74 def __init__(self, body: list[stmt]) -> None: ...
75
76 if sys.version_info >= (3, 14):
77 def __replace__(self, *, body: list[stmt] = ...) -> Self: ...
78
79 class Expression(mod):
80 if sys.version_info >= (3, 10):
81 __match_args__ = ("body",)
82 body: expr
83 def __init__(self, body: expr) -> None: ...
84
85 if sys.version_info >= (3, 14):
86 def __replace__(self, *, body: expr = ...) -> Self: ...
87
88 class FunctionType(mod):
89 if sys.version_info >= (3, 10):
90 __match_args__ = ("argtypes", "returns")
91 argtypes: list[expr]
92 returns: expr
93 if sys.version_info >= (3, 13):
94 @overload
95 def __init__(self, argtypes: list[expr], returns: expr) -> None: ...
96 @overload
97 def __init__(self, argtypes: list[expr] = ..., *, returns: expr) -> None: ...
98 else:
99 def __init__(self, argtypes: list[expr], returns: expr) -> None: ...
100
101 if sys.version_info >= (3, 14):
102 def __replace__(self, *, argtypes: list[expr] = ..., returns: expr = ...) -> Self: ...
103
104 class stmt(AST):
105 lineno: int
106 col_offset: int
107 end_lineno: int | None
108 end_col_offset: int | None
109 def __init__(self, **kwargs: Unpack[_Attributes]) -> None: ...
110
111 if sys.version_info >= (3, 14):
112 def __replace__(self, **kwargs: Unpack[_Attributes]) -> Self: ...
113
114 class FunctionDef(stmt):
115 if sys.version_info >= (3, 12):
116 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
117 elif sys.version_info >= (3, 10):
118 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
119 name: str
120 args: arguments
121 body: list[stmt]
122 decorator_list: list[expr]
123 returns: expr | None
124 type_comment: str | None
125 if sys.version_info >= (3, 12):
126 type_params: list[type_param]
127 if sys.version_info >= (3, 13):
128 def __init__(
129 self,
130 name: str,
131 args: arguments,
132 body: list[stmt] = ...,
133 decorator_list: list[expr] = ...,
134 returns: expr | None = None,
135 type_comment: str | None = None,
136 type_params: list[type_param] = ...,
137 **kwargs: Unpack[_Attributes],
138 ) -> None: ...
139 elif sys.version_info >= (3, 12):
140 @overload
141 def __init__(
142 self,
143 name: str,
144 args: arguments,
145 body: list[stmt],
146 decorator_list: list[expr],
147 returns: expr | None,
148 type_comment: str | None,
149 type_params: list[type_param],
150 **kwargs: Unpack[_Attributes],
151 ) -> None: ...
152 @overload
153 def __init__(
154 self,
155 name: str,
156 args: arguments,
157 body: list[stmt],
158 decorator_list: list[expr],
159 returns: expr | None = None,
160 type_comment: str | None = None,
161 *,
162 type_params: list[type_param],
163 **kwargs: Unpack[_Attributes],
164 ) -> None: ...
165 else:
166 def __init__(
167 self,
168 name: str,
169 args: arguments,
170 body: list[stmt],
171 decorator_list: list[expr],
172 returns: expr | None = None,
173 type_comment: str | None = None,
174 **kwargs: Unpack[_Attributes],
175 ) -> None: ...
176
177 if sys.version_info >= (3, 14):
178 def __replace__(
179 self,
180 *,
181 name: str = ...,
182 args: arguments = ...,
183 body: list[stmt] = ...,
184 decorator_list: list[expr] = ...,
185 returns: expr | None = ...,
186 type_comment: str | None = ...,
187 type_params: list[type_param] = ...,
188 **kwargs: Unpack[_Attributes],
189 ) -> Self: ...
190
191 class AsyncFunctionDef(stmt):
192 if sys.version_info >= (3, 12):
193 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
194 elif sys.version_info >= (3, 10):
195 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
196 name: str
197 args: arguments
198 body: list[stmt]
199 decorator_list: list[expr]
200 returns: expr | None
201 type_comment: str | None
202 if sys.version_info >= (3, 12):
203 type_params: list[type_param]
204 if sys.version_info >= (3, 13):
205 def __init__(
206 self,
207 name: str,
208 args: arguments,
209 body: list[stmt] = ...,
210 decorator_list: list[expr] = ...,
211 returns: expr | None = None,
212 type_comment: str | None = None,
213 type_params: list[type_param] = ...,
214 **kwargs: Unpack[_Attributes],
215 ) -> None: ...
216 elif sys.version_info >= (3, 12):
217 @overload
218 def __init__(
219 self,
220 name: str,
221 args: arguments,
222 body: list[stmt],
223 decorator_list: list[expr],
224 returns: expr | None,
225 type_comment: str | None,
226 type_params: list[type_param],
227 **kwargs: Unpack[_Attributes],
228 ) -> None: ...
229 @overload
230 def __init__(
231 self,
232 name: str,
233 args: arguments,
234 body: list[stmt],
235 decorator_list: list[expr],
236 returns: expr | None = None,
237 type_comment: str | None = None,
238 *,
239 type_params: list[type_param],
240 **kwargs: Unpack[_Attributes],
241 ) -> None: ...
242 else:
243 def __init__(
244 self,
245 name: str,
246 args: arguments,
247 body: list[stmt],
248 decorator_list: list[expr],
249 returns: expr | None = None,
250 type_comment: str | None = None,
251 **kwargs: Unpack[_Attributes],
252 ) -> None: ...
253
254 if sys.version_info >= (3, 14):
255 def __replace__(
256 self,
257 *,
258 name: str = ...,
259 args: arguments = ...,
260 body: list[stmt] = ...,
261 decorator_list: list[expr] = ...,
262 returns: expr | None = ...,
263 type_comment: str | None = ...,
264 type_params: list[type_param] = ...,
265 **kwargs: Unpack[_Attributes],
266 ) -> Self: ...
267
268 class ClassDef(stmt):
269 if sys.version_info >= (3, 12):
270 __match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params")
271 elif sys.version_info >= (3, 10):
272 __match_args__ = ("name", "bases", "keywords", "body", "decorator_list")
273 name: str
274 bases: list[expr]
275 keywords: list[keyword]
276 body: list[stmt]
277 decorator_list: list[expr]
278 if sys.version_info >= (3, 12):
279 type_params: list[type_param]
280 if sys.version_info >= (3, 13):
281 def __init__(
282 self,
283 name: str,
284 bases: list[expr] = ...,
285 keywords: list[keyword] = ...,
286 body: list[stmt] = ...,
287 decorator_list: list[expr] = ...,
288 type_params: list[type_param] = ...,
289 **kwargs: Unpack[_Attributes],
290 ) -> None: ...
291 elif sys.version_info >= (3, 12):
292 def __init__(
293 self,
294 name: str,
295 bases: list[expr],
296 keywords: list[keyword],
297 body: list[stmt],
298 decorator_list: list[expr],
299 type_params: list[type_param],
300 **kwargs: Unpack[_Attributes],
301 ) -> None: ...
302 else:
303 def __init__(
304 self,
305 name: str,
306 bases: list[expr],
307 keywords: list[keyword],
308 body: list[stmt],
309 decorator_list: list[expr],
310 **kwargs: Unpack[_Attributes],
311 ) -> None: ...
312
313 if sys.version_info >= (3, 14):
314 def __replace__(
315 self,
316 *,
317 name: str = ...,
318 bases: list[expr] = ...,
319 keywords: list[keyword] = ...,
320 body: list[stmt] = ...,
321 decorator_list: list[expr] = ...,
322 type_params: list[type_param] = ...,
323 **kwargs: Unpack[_Attributes],
324 ) -> Self: ...
325
326 class Return(stmt):
327 if sys.version_info >= (3, 10):
328 __match_args__ = ("value",)
329 value: expr | None
330 def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
331
332 if sys.version_info >= (3, 14):
333 def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
334
335 class Delete(stmt):
336 if sys.version_info >= (3, 10):
337 __match_args__ = ("targets",)
338 targets: list[expr]
339 if sys.version_info >= (3, 13):
340 def __init__(self, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
341 else:
342 def __init__(self, targets: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
343
344 if sys.version_info >= (3, 14):
345 def __replace__(self, *, targets: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
346
347 class Assign(stmt):
348 if sys.version_info >= (3, 10):
349 __match_args__ = ("targets", "value", "type_comment")
350 targets: list[expr]
351 value: expr
352 type_comment: str | None
353 if sys.version_info >= (3, 13):
354 @overload
355 def __init__(
356 self, targets: list[expr], value: expr, type_comment: str | None = None, **kwargs: Unpack[_Attributes]
357 ) -> None: ...
358 @overload
359 def __init__(
360 self, targets: list[expr] = ..., *, value: expr, type_comment: str | None = None, **kwargs: Unpack[_Attributes]
361 ) -> None: ...
362 else:
363 def __init__(
364 self, targets: list[expr], value: expr, type_comment: str | None = None, **kwargs: Unpack[_Attributes]
365 ) -> None: ...
366
367 if sys.version_info >= (3, 14):
368 def __replace__(
369 self, *, targets: list[expr] = ..., value: expr = ..., type_comment: str | None = ..., **kwargs: Unpack[_Attributes]
370 ) -> Self: ...
371
372 if sys.version_info >= (3, 12):
373 class TypeAlias(stmt):
374 __match_args__ = ("name", "type_params", "value")
375 name: Name
376 type_params: list[type_param]
377 value: expr
378 if sys.version_info >= (3, 13):
379 @overload
380 def __init__(
381 self, name: Name, type_params: list[type_param], value: expr, **kwargs: Unpack[_Attributes[int]]
382 ) -> None: ...
383 @overload
384 def __init__(
385 self, name: Name, type_params: list[type_param] = ..., *, value: expr, **kwargs: Unpack[_Attributes[int]]
386 ) -> None: ...
387 else:
388 def __init__(
389 self, name: Name, type_params: list[type_param], value: expr, **kwargs: Unpack[_Attributes[int]]
390 ) -> None: ...
391
392 if sys.version_info >= (3, 14):
393 def __replace__( # type: ignore[override]
394 self,
395 *,
396 name: Name = ...,
397 type_params: list[type_param] = ...,
398 value: expr = ...,
399 **kwargs: Unpack[_Attributes[int]],
400 ) -> Self: ...
401
402 class AugAssign(stmt):
403 if sys.version_info >= (3, 10):
404 __match_args__ = ("target", "op", "value")
405 target: Name | Attribute | Subscript
406 op: operator
407 value: expr
408 def __init__(
409 self, target: Name | Attribute | Subscript, op: operator, value: expr, **kwargs: Unpack[_Attributes]
410 ) -> None: ...
411
412 if sys.version_info >= (3, 14):
413 def __replace__(
414 self,
415 *,
416 target: Name | Attribute | Subscript = ...,
417 op: operator = ...,
418 value: expr = ...,
419 **kwargs: Unpack[_Attributes],
420 ) -> Self: ...
421
422 class AnnAssign(stmt):
423 if sys.version_info >= (3, 10):
424 __match_args__ = ("target", "annotation", "value", "simple")
425 target: Name | Attribute | Subscript
426 annotation: expr
427 value: expr | None
428 simple: int
429 @overload
430 def __init__(
431 self,
432 target: Name | Attribute | Subscript,
433 annotation: expr,
434 value: expr | None,
435 simple: int,
436 **kwargs: Unpack[_Attributes],
437 ) -> None: ...
438 @overload
439 def __init__(
440 self,
441 target: Name | Attribute | Subscript,
442 annotation: expr,
443 value: expr | None = None,
444 *,
445 simple: int,
446 **kwargs: Unpack[_Attributes],
447 ) -> None: ...
448
449 if sys.version_info >= (3, 14):
450 def __replace__(
451 self,
452 *,
453 target: Name | Attribute | Subscript = ...,
454 annotation: expr = ...,
455 value: expr | None = ...,
456 simple: int = ...,
457 **kwargs: Unpack[_Attributes],
458 ) -> Self: ...
459
460 class For(stmt):
461 if sys.version_info >= (3, 10):
462 __match_args__ = ("target", "iter", "body", "orelse", "type_comment")
463 target: expr
464 iter: expr
465 body: list[stmt]
466 orelse: list[stmt]
467 type_comment: str | None
468 if sys.version_info >= (3, 13):
469 def __init__(
470 self,
471 target: expr,
472 iter: expr,
473 body: list[stmt] = ...,
474 orelse: list[stmt] = ...,
475 type_comment: str | None = None,
476 **kwargs: Unpack[_Attributes],
477 ) -> None: ...
478 else:
479 def __init__(
480 self,
481 target: expr,
482 iter: expr,
483 body: list[stmt],
484 orelse: list[stmt],
485 type_comment: str | None = None,
486 **kwargs: Unpack[_Attributes],
487 ) -> None: ...
488
489 if sys.version_info >= (3, 14):
490 def __replace__(
491 self,
492 *,
493 target: expr = ...,
494 iter: expr = ...,
495 body: list[stmt] = ...,
496 orelse: list[stmt] = ...,
497 type_comment: str | None = ...,
498 **kwargs: Unpack[_Attributes],
499 ) -> Self: ...
500
501 class AsyncFor(stmt):
502 if sys.version_info >= (3, 10):
503 __match_args__ = ("target", "iter", "body", "orelse", "type_comment")
504 target: expr
505 iter: expr
506 body: list[stmt]
507 orelse: list[stmt]
508 type_comment: str | None
509 if sys.version_info >= (3, 13):
510 def __init__(
511 self,
512 target: expr,
513 iter: expr,
514 body: list[stmt] = ...,
515 orelse: list[stmt] = ...,
516 type_comment: str | None = None,
517 **kwargs: Unpack[_Attributes],
518 ) -> None: ...
519 else:
520 def __init__(
521 self,
522 target: expr,
523 iter: expr,
524 body: list[stmt],
525 orelse: list[stmt],
526 type_comment: str | None = None,
527 **kwargs: Unpack[_Attributes],
528 ) -> None: ...
529
530 if sys.version_info >= (3, 14):
531 def __replace__(
532 self,
533 *,
534 target: expr = ...,
535 iter: expr = ...,
536 body: list[stmt] = ...,
537 orelse: list[stmt] = ...,
538 type_comment: str | None = ...,
539 **kwargs: Unpack[_Attributes],
540 ) -> Self: ...
541
542 class While(stmt):
543 if sys.version_info >= (3, 10):
544 __match_args__ = ("test", "body", "orelse")
545 test: expr
546 body: list[stmt]
547 orelse: list[stmt]
548 if sys.version_info >= (3, 13):
549 def __init__(
550 self, test: expr, body: list[stmt] = ..., orelse: list[stmt] = ..., **kwargs: Unpack[_Attributes]
551 ) -> None: ...
552 else:
553 def __init__(self, test: expr, body: list[stmt], orelse: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ...
554
555 if sys.version_info >= (3, 14):
556 def __replace__(
557 self, *, test: expr = ..., body: list[stmt] = ..., orelse: list[stmt] = ..., **kwargs: Unpack[_Attributes]
558 ) -> Self: ...
559
560 class If(stmt):
561 if sys.version_info >= (3, 10):
562 __match_args__ = ("test", "body", "orelse")
563 test: expr
564 body: list[stmt]
565 orelse: list[stmt]
566 if sys.version_info >= (3, 13):
567 def __init__(
568 self, test: expr, body: list[stmt] = ..., orelse: list[stmt] = ..., **kwargs: Unpack[_Attributes]
569 ) -> None: ...
570 else:
571 def __init__(self, test: expr, body: list[stmt], orelse: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ...
572
573 if sys.version_info >= (3, 14):
574 def __replace__(
575 self, *, test: expr = ..., body: list[stmt] = ..., orelse: list[stmt] = ..., **kwargs: Unpack[_Attributes]
576 ) -> Self: ...
577
578 class With(stmt):
579 if sys.version_info >= (3, 10):
580 __match_args__ = ("items", "body", "type_comment")
581 items: list[withitem]
582 body: list[stmt]
583 type_comment: str | None
584 if sys.version_info >= (3, 13):
585 def __init__(
586 self,
587 items: list[withitem] = ...,
588 body: list[stmt] = ...,
589 type_comment: str | None = None,
590 **kwargs: Unpack[_Attributes],
591 ) -> None: ...
592 else:
593 def __init__(
594 self, items: list[withitem], body: list[stmt], type_comment: str | None = None, **kwargs: Unpack[_Attributes]
595 ) -> None: ...
596
597 if sys.version_info >= (3, 14):
598 def __replace__(
599 self,
600 *,
601 items: list[withitem] = ...,
602 body: list[stmt] = ...,
603 type_comment: str | None = ...,
604 **kwargs: Unpack[_Attributes],
605 ) -> Self: ...
606
607 class AsyncWith(stmt):
608 if sys.version_info >= (3, 10):
609 __match_args__ = ("items", "body", "type_comment")
610 items: list[withitem]
611 body: list[stmt]
612 type_comment: str | None
613 if sys.version_info >= (3, 13):
614 def __init__(
615 self,
616 items: list[withitem] = ...,
617 body: list[stmt] = ...,
618 type_comment: str | None = None,
619 **kwargs: Unpack[_Attributes],
620 ) -> None: ...
621 else:
622 def __init__(
623 self, items: list[withitem], body: list[stmt], type_comment: str | None = None, **kwargs: Unpack[_Attributes]
624 ) -> None: ...
625
626 if sys.version_info >= (3, 14):
627 def __replace__(
628 self,
629 *,
630 items: list[withitem] = ...,
631 body: list[stmt] = ...,
632 type_comment: str | None = ...,
633 **kwargs: Unpack[_Attributes],
634 ) -> Self: ...
635
636 class Raise(stmt):
637 if sys.version_info >= (3, 10):
638 __match_args__ = ("exc", "cause")
639 exc: expr | None
640 cause: expr | None
641 def __init__(self, exc: expr | None = None, cause: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
642
643 if sys.version_info >= (3, 14):
644 def __replace__(self, *, exc: expr | None = ..., cause: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
645
646 class Try(stmt):
647 if sys.version_info >= (3, 10):
648 __match_args__ = ("body", "handlers", "orelse", "finalbody")
649 body: list[stmt]
650 handlers: list[ExceptHandler]
651 orelse: list[stmt]
652 finalbody: list[stmt]
653 if sys.version_info >= (3, 13):
654 def __init__(
655 self,
656 body: list[stmt] = ...,
657 handlers: list[ExceptHandler] = ...,
658 orelse: list[stmt] = ...,
659 finalbody: list[stmt] = ...,
660 **kwargs: Unpack[_Attributes],
661 ) -> None: ...
662 else:
663 def __init__(
664 self,
665 body: list[stmt],
666 handlers: list[ExceptHandler],
667 orelse: list[stmt],
668 finalbody: list[stmt],
669 **kwargs: Unpack[_Attributes],
670 ) -> None: ...
671
672 if sys.version_info >= (3, 14):
673 def __replace__(
674 self,
675 *,
676 body: list[stmt] = ...,
677 handlers: list[ExceptHandler] = ...,
678 orelse: list[stmt] = ...,
679 finalbody: list[stmt] = ...,
680 **kwargs: Unpack[_Attributes],
681 ) -> Self: ...
682
683 if sys.version_info >= (3, 11):
684 class TryStar(stmt):
685 __match_args__ = ("body", "handlers", "orelse", "finalbody")
686 body: list[stmt]
687 handlers: list[ExceptHandler]
688 orelse: list[stmt]
689 finalbody: list[stmt]
690 if sys.version_info >= (3, 13):
691 def __init__(
692 self,
693 body: list[stmt] = ...,
694 handlers: list[ExceptHandler] = ...,
695 orelse: list[stmt] = ...,
696 finalbody: list[stmt] = ...,
697 **kwargs: Unpack[_Attributes],
698 ) -> None: ...
699 else:
700 def __init__(
701 self,
702 body: list[stmt],
703 handlers: list[ExceptHandler],
704 orelse: list[stmt],
705 finalbody: list[stmt],
706 **kwargs: Unpack[_Attributes],
707 ) -> None: ...
708
709 if sys.version_info >= (3, 14):
710 def __replace__(
711 self,
712 *,
713 body: list[stmt] = ...,
714 handlers: list[ExceptHandler] = ...,
715 orelse: list[stmt] = ...,
716 finalbody: list[stmt] = ...,
717 **kwargs: Unpack[_Attributes],
718 ) -> Self: ...
719
720 class Assert(stmt):
721 if sys.version_info >= (3, 10):
722 __match_args__ = ("test", "msg")
723 test: expr
724 msg: expr | None
725 def __init__(self, test: expr, msg: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
726
727 if sys.version_info >= (3, 14):
728 def __replace__(self, *, test: expr = ..., msg: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
729
730 class Import(stmt):
731 if sys.version_info >= (3, 10):
732 __match_args__ = ("names",)
733 names: list[alias]
734 if sys.version_info >= (3, 13):
735 def __init__(self, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
736 else:
737 def __init__(self, names: list[alias], **kwargs: Unpack[_Attributes]) -> None: ...
738
739 if sys.version_info >= (3, 14):
740 def __replace__(self, *, names: list[alias] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
741
742 class ImportFrom(stmt):
743 if sys.version_info >= (3, 10):
744 __match_args__ = ("module", "names", "level")
745 module: str | None
746 names: list[alias]
747 level: int
748 if sys.version_info >= (3, 13):
749 @overload
750 def __init__(self, module: str | None, names: list[alias], level: int, **kwargs: Unpack[_Attributes]) -> None: ...
751 @overload
752 def __init__(
753 self, module: str | None = None, names: list[alias] = ..., *, level: int, **kwargs: Unpack[_Attributes]
754 ) -> None: ...
755 else:
756 @overload
757 def __init__(self, module: str | None, names: list[alias], level: int, **kwargs: Unpack[_Attributes]) -> None: ...
758 @overload
759 def __init__(
760 self, module: str | None = None, *, names: list[alias], level: int, **kwargs: Unpack[_Attributes]
761 ) -> None: ...
762
763 if sys.version_info >= (3, 14):
764 def __replace__(
765 self, *, module: str | None = ..., names: list[alias] = ..., level: int = ..., **kwargs: Unpack[_Attributes]
766 ) -> Self: ...
767
768 class Global(stmt):
769 if sys.version_info >= (3, 10):
770 __match_args__ = ("names",)
771 names: list[str]
772 if sys.version_info >= (3, 13):
773 def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
774 else:
775 def __init__(self, names: list[str], **kwargs: Unpack[_Attributes]) -> None: ...
776
777 if sys.version_info >= (3, 14):
778 def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
779
780 class Nonlocal(stmt):
781 if sys.version_info >= (3, 10):
782 __match_args__ = ("names",)
783 names: list[str]
784 if sys.version_info >= (3, 13):
785 def __init__(self, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
786 else:
787 def __init__(self, names: list[str], **kwargs: Unpack[_Attributes]) -> None: ...
788
789 if sys.version_info >= (3, 14):
790 def __replace__(self, *, names: list[str] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
791
792 class Expr(stmt):
793 if sys.version_info >= (3, 10):
794 __match_args__ = ("value",)
795 value: expr
796 def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
797
798 if sys.version_info >= (3, 14):
799 def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
800
801 class Pass(stmt): ...
802 class Break(stmt): ...
803 class Continue(stmt): ...
804
805 class expr(AST):
806 lineno: int
807 col_offset: int
808 end_lineno: int | None
809 end_col_offset: int | None
810 def __init__(self, **kwargs: Unpack[_Attributes]) -> None: ...
811
812 if sys.version_info >= (3, 14):
813 def __replace__(self, **kwargs: Unpack[_Attributes]) -> Self: ...
814
815 class BoolOp(expr):
816 if sys.version_info >= (3, 10):
817 __match_args__ = ("op", "values")
818 op: boolop
819 values: list[expr]
820 if sys.version_info >= (3, 13):
821 def __init__(self, op: boolop, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
822 else:
823 def __init__(self, op: boolop, values: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
824
825 if sys.version_info >= (3, 14):
826 def __replace__(self, *, op: boolop = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
827
828 class NamedExpr(expr):
829 if sys.version_info >= (3, 10):
830 __match_args__ = ("target", "value")
831 target: Name
832 value: expr
833 def __init__(self, target: Name, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
834
835 if sys.version_info >= (3, 14):
836 def __replace__(self, *, target: Name = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
837
838 class BinOp(expr):
839 if sys.version_info >= (3, 10):
840 __match_args__ = ("left", "op", "right")
841 left: expr
842 op: operator
843 right: expr
844 def __init__(self, left: expr, op: operator, right: expr, **kwargs: Unpack[_Attributes]) -> None: ...
845
846 if sys.version_info >= (3, 14):
847 def __replace__(
848 self, *, left: expr = ..., op: operator = ..., right: expr = ..., **kwargs: Unpack[_Attributes]
849 ) -> Self: ...
850
851 class UnaryOp(expr):
852 if sys.version_info >= (3, 10):
853 __match_args__ = ("op", "operand")
854 op: unaryop
855 operand: expr
856 def __init__(self, op: unaryop, operand: expr, **kwargs: Unpack[_Attributes]) -> None: ...
857
858 if sys.version_info >= (3, 14):
859 def __replace__(self, *, op: unaryop = ..., operand: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
860
861 class Lambda(expr):
862 if sys.version_info >= (3, 10):
863 __match_args__ = ("args", "body")
864 args: arguments
865 body: expr
866 def __init__(self, args: arguments, body: expr, **kwargs: Unpack[_Attributes]) -> None: ...
867
868 if sys.version_info >= (3, 14):
869 def __replace__(self, *, args: arguments = ..., body: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
870
871 class IfExp(expr):
872 if sys.version_info >= (3, 10):
873 __match_args__ = ("test", "body", "orelse")
874 test: expr
875 body: expr
876 orelse: expr
877 def __init__(self, test: expr, body: expr, orelse: expr, **kwargs: Unpack[_Attributes]) -> None: ...
878
879 if sys.version_info >= (3, 14):
880 def __replace__(
881 self, *, test: expr = ..., body: expr = ..., orelse: expr = ..., **kwargs: Unpack[_Attributes]
882 ) -> Self: ...
883
884 class Dict(expr):
885 if sys.version_info >= (3, 10):
886 __match_args__ = ("keys", "values")
887 keys: list[expr | None]
888 values: list[expr]
889 if sys.version_info >= (3, 13):
890 def __init__(self, keys: list[expr | None] = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
891 else:
892 def __init__(self, keys: list[expr | None], values: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
893
894 if sys.version_info >= (3, 14):
895 def __replace__(
896 self, *, keys: list[expr | None] = ..., values: list[expr] = ..., **kwargs: Unpack[_Attributes]
897 ) -> Self: ...
898
899 class Set(expr):
900 if sys.version_info >= (3, 10):
901 __match_args__ = ("elts",)
902 elts: list[expr]
903 if sys.version_info >= (3, 13):
904 def __init__(self, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
905 else:
906 def __init__(self, elts: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
907
908 if sys.version_info >= (3, 14):
909 def __replace__(self, *, elts: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
910
911 class ListComp(expr):
912 if sys.version_info >= (3, 10):
913 __match_args__ = ("elt", "generators")
914 elt: expr
915 generators: list[comprehension]
916 if sys.version_info >= (3, 13):
917 def __init__(self, elt: expr, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
918 else:
919 def __init__(self, elt: expr, generators: list[comprehension], **kwargs: Unpack[_Attributes]) -> None: ...
920
921 if sys.version_info >= (3, 14):
922 def __replace__(
923 self, *, elt: expr = ..., generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
924 ) -> Self: ...
925
926 class SetComp(expr):
927 if sys.version_info >= (3, 10):
928 __match_args__ = ("elt", "generators")
929 elt: expr
930 generators: list[comprehension]
931 if sys.version_info >= (3, 13):
932 def __init__(self, elt: expr, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
933 else:
934 def __init__(self, elt: expr, generators: list[comprehension], **kwargs: Unpack[_Attributes]) -> None: ...
935
936 if sys.version_info >= (3, 14):
937 def __replace__(
938 self, *, elt: expr = ..., generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
939 ) -> Self: ...
940
941 class DictComp(expr):
942 if sys.version_info >= (3, 10):
943 __match_args__ = ("key", "value", "generators")
944 key: expr
945 value: expr
946 generators: list[comprehension]
947 if sys.version_info >= (3, 13):
948 def __init__(
949 self, key: expr, value: expr, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
950 ) -> None: ...
951 else:
952 def __init__(self, key: expr, value: expr, generators: list[comprehension], **kwargs: Unpack[_Attributes]) -> None: ...
953
954 if sys.version_info >= (3, 14):
955 def __replace__(
956 self, *, key: expr = ..., value: expr = ..., generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
957 ) -> Self: ...
958
959 class GeneratorExp(expr):
960 if sys.version_info >= (3, 10):
961 __match_args__ = ("elt", "generators")
962 elt: expr
963 generators: list[comprehension]
964 if sys.version_info >= (3, 13):
965 def __init__(self, elt: expr, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
966 else:
967 def __init__(self, elt: expr, generators: list[comprehension], **kwargs: Unpack[_Attributes]) -> None: ...
968
969 if sys.version_info >= (3, 14):
970 def __replace__(
971 self, *, elt: expr = ..., generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
972 ) -> Self: ...
973
974 class Await(expr):
975 if sys.version_info >= (3, 10):
976 __match_args__ = ("value",)
977 value: expr
978 def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
979
980 if sys.version_info >= (3, 14):
981 def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
982
983 class Yield(expr):
984 if sys.version_info >= (3, 10):
985 __match_args__ = ("value",)
986 value: expr | None
987 def __init__(self, value: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
988
989 if sys.version_info >= (3, 14):
990 def __replace__(self, *, value: expr | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
991
992 class YieldFrom(expr):
993 if sys.version_info >= (3, 10):
994 __match_args__ = ("value",)
995 value: expr
996 def __init__(self, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
997
998 if sys.version_info >= (3, 14):
999 def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1000
1001 class Compare(expr):
1002 if sys.version_info >= (3, 10):
1003 __match_args__ = ("left", "ops", "comparators")
1004 left: expr
1005 ops: list[cmpop]
1006 comparators: list[expr]
1007 if sys.version_info >= (3, 13):
1008 def __init__(
1009 self, left: expr, ops: list[cmpop] = ..., comparators: list[expr] = ..., **kwargs: Unpack[_Attributes]
1010 ) -> None: ...
1011 else:
1012 def __init__(self, left: expr, ops: list[cmpop], comparators: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
1013
1014 if sys.version_info >= (3, 14):
1015 def __replace__(
1016 self, *, left: expr = ..., ops: list[cmpop] = ..., comparators: list[expr] = ..., **kwargs: Unpack[_Attributes]
1017 ) -> Self: ...
1018
1019 class Call(expr):
1020 if sys.version_info >= (3, 10):
1021 __match_args__ = ("func", "args", "keywords")
1022 func: expr
1023 args: list[expr]
1024 keywords: list[keyword]
1025 if sys.version_info >= (3, 13):
1026 def __init__(
1027 self, func: expr, args: list[expr] = ..., keywords: list[keyword] = ..., **kwargs: Unpack[_Attributes]
1028 ) -> None: ...
1029 else:
1030 def __init__(self, func: expr, args: list[expr], keywords: list[keyword], **kwargs: Unpack[_Attributes]) -> None: ...
1031
1032 if sys.version_info >= (3, 14):
1033 def __replace__(
1034 self, *, func: expr = ..., args: list[expr] = ..., keywords: list[keyword] = ..., **kwargs: Unpack[_Attributes]
1035 ) -> Self: ...
1036
1037 class FormattedValue(expr):
1038 if sys.version_info >= (3, 10):
1039 __match_args__ = ("value", "conversion", "format_spec")
1040 value: expr
1041 conversion: int
1042 format_spec: expr | None
1043 def __init__(self, value: expr, conversion: int, format_spec: expr | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1044
1045 if sys.version_info >= (3, 14):
1046 def __replace__(
1047 self, *, value: expr = ..., conversion: int = ..., format_spec: expr | None = ..., **kwargs: Unpack[_Attributes]
1048 ) -> Self: ...
1049
1050 class JoinedStr(expr):
1051 if sys.version_info >= (3, 10):
1052 __match_args__ = ("values",)
1053 values: list[expr]
1054 if sys.version_info >= (3, 13):
1055 def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1056 else:
1057 def __init__(self, values: list[expr], **kwargs: Unpack[_Attributes]) -> None: ...
1058
1059 if sys.version_info >= (3, 14):
1060 def __replace__(self, *, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1061
1062 if sys.version_info >= (3, 14):
1063 class TemplateStr(expr):
1064 __match_args__ = ("values",)
1065 values: list[expr]
1066 def __init__(self, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1067 def __replace__(self, *, values: list[expr] = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1068
1069 class Interpolation(expr):
1070 __match_args__ = ("value", "str", "conversion", "format_spec")
1071 value: expr
1072 str: builtins.str
1073 conversion: int
1074 format_spec: expr | None = None
1075 def __init__(
1076 self,
1077 value: expr = ...,
1078 str: builtins.str = ...,
1079 conversion: int = ...,
1080 format_spec: expr | None = ...,
1081 **kwargs: Unpack[_Attributes],
1082 ) -> None: ...
1083 def __replace__(
1084 self,
1085 *,
1086 value: expr = ...,
1087 str: builtins.str = ...,
1088 conversion: int = ...,
1089 format_spec: expr | None = ...,
1090 **kwargs: Unpack[_Attributes],
1091 ) -> Self: ...
1092
1093 if sys.version_info >= (3, 10):
1094 from types import EllipsisType
1095
1096 _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType
1097 else:
1098 # Rely on builtins.ellipsis
1099 _ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821
1100
1101 class Constant(expr):
1102 if sys.version_info >= (3, 10):
1103 __match_args__ = ("value", "kind")
1104 value: _ConstantValue
1105 kind: str | None
1106 if sys.version_info < (3, 14):
1107 # Aliases for value, for backwards compatibility
1108 @property
1109 @deprecated("Removed in Python 3.14. Use `value` instead.")
1110 def n(self) -> _ConstantValue: ...
1111 @n.setter
1112 @deprecated("Removed in Python 3.14. Use `value` instead.")
1113 def n(self, value: _ConstantValue) -> None: ...
1114 @property
1115 @deprecated("Removed in Python 3.14. Use `value` instead.")
1116 def s(self) -> _ConstantValue: ...
1117 @s.setter
1118 @deprecated("Removed in Python 3.14. Use `value` instead.")
1119 def s(self, value: _ConstantValue) -> None: ...
1120
1121 def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1122
1123 if sys.version_info >= (3, 14):
1124 def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1125
1126 class Attribute(expr):
1127 if sys.version_info >= (3, 10):
1128 __match_args__ = ("value", "attr", "ctx")
1129 value: expr
1130 attr: str
1131 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1132 def __init__(self, value: expr, attr: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1133
1134 if sys.version_info >= (3, 14):
1135 def __replace__(
1136 self, *, value: expr = ..., attr: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]
1137 ) -> Self: ...
1138
1139 class Subscript(expr):
1140 if sys.version_info >= (3, 10):
1141 __match_args__ = ("value", "slice", "ctx")
1142 value: expr
1143 slice: expr
1144 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1145 def __init__(self, value: expr, slice: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1146
1147 if sys.version_info >= (3, 14):
1148 def __replace__(
1149 self, *, value: expr = ..., slice: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]
1150 ) -> Self: ...
1151
1152 class Starred(expr):
1153 if sys.version_info >= (3, 10):
1154 __match_args__ = ("value", "ctx")
1155 value: expr
1156 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1157 def __init__(self, value: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1158
1159 if sys.version_info >= (3, 14):
1160 def __replace__(self, *, value: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1161
1162 class Name(expr):
1163 if sys.version_info >= (3, 10):
1164 __match_args__ = ("id", "ctx")
1165 id: str
1166 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1167 def __init__(self, id: str, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1168
1169 if sys.version_info >= (3, 14):
1170 def __replace__(self, *, id: str = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1171
1172 class List(expr):
1173 if sys.version_info >= (3, 10):
1174 __match_args__ = ("elts", "ctx")
1175 elts: list[expr]
1176 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1177 if sys.version_info >= (3, 13):
1178 def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1179 else:
1180 def __init__(self, elts: list[expr], ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1181
1182 if sys.version_info >= (3, 14):
1183 def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1184
1185 class Tuple(expr):
1186 if sys.version_info >= (3, 10):
1187 __match_args__ = ("elts", "ctx")
1188 elts: list[expr]
1189 ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
1190 dims: list[expr]
1191 if sys.version_info >= (3, 13):
1192 def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1193 else:
1194 def __init__(self, elts: list[expr], ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1195
1196 if sys.version_info >= (3, 14):
1197 def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1198
1199 @deprecated("Deprecated since Python 3.9.")
1200 class slice(AST): ...
1201
1202 class Slice(expr):
1203 if sys.version_info >= (3, 10):
1204 __match_args__ = ("lower", "upper", "step")
1205 lower: expr | None
1206 upper: expr | None
1207 step: expr | None
1208 def __init__(
1209 self, lower: expr | None = None, upper: expr | None = None, step: expr | None = None, **kwargs: Unpack[_Attributes]
1210 ) -> None: ...
1211
1212 if sys.version_info >= (3, 14):
1213 def __replace__(
1214 self, *, lower: expr | None = ..., upper: expr | None = ..., step: expr | None = ..., **kwargs: Unpack[_Attributes]
1215 ) -> Self: ...
1216
1217 @deprecated("Deprecated since Python 3.9. Use `ast.Tuple` instead.")
1218 class ExtSlice(slice):
1219 def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_Attributes]) -> Tuple: ... # type: ignore[misc]
1220
1221 @deprecated("Deprecated since Python 3.9. Use the index value directly instead.")
1222 class Index(slice):
1223 def __new__(cls, value: expr, **kwargs: Unpack[_Attributes]) -> expr: ... # type: ignore[misc]
1224
1225 class expr_context(AST): ...
1226
1227 @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1228 class AugLoad(expr_context): ...
1229
1230 @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1231 class AugStore(expr_context): ...
1232
1233 @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1234 class Param(expr_context): ...
1235
1236 @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
1237 class Suite(mod): ...
1238
1239 class Load(expr_context): ...
1240 class Store(expr_context): ...
1241 class Del(expr_context): ...
1242 class boolop(AST): ...
1243 class And(boolop): ...
1244 class Or(boolop): ...
1245 class operator(AST): ...
1246 class Add(operator): ...
1247 class Sub(operator): ...
1248 class Mult(operator): ...
1249 class MatMult(operator): ...
1250 class Div(operator): ...
1251 class Mod(operator): ...
1252 class Pow(operator): ...
1253 class LShift(operator): ...
1254 class RShift(operator): ...
1255 class BitOr(operator): ...
1256 class BitXor(operator): ...
1257 class BitAnd(operator): ...
1258 class FloorDiv(operator): ...
1259 class unaryop(AST): ...
1260 class Invert(unaryop): ...
1261 class Not(unaryop): ...
1262 class UAdd(unaryop): ...
1263 class USub(unaryop): ...
1264 class cmpop(AST): ...
1265 class Eq(cmpop): ...
1266 class NotEq(cmpop): ...
1267 class Lt(cmpop): ...
1268 class LtE(cmpop): ...
1269 class Gt(cmpop): ...
1270 class GtE(cmpop): ...
1271 class Is(cmpop): ...
1272 class IsNot(cmpop): ...
1273 class In(cmpop): ...
1274 class NotIn(cmpop): ...
1275
1276 class comprehension(AST):
1277 if sys.version_info >= (3, 10):
1278 __match_args__ = ("target", "iter", "ifs", "is_async")
1279 target: expr
1280 iter: expr
1281 ifs: list[expr]
1282 is_async: int
1283 if sys.version_info >= (3, 13):
1284 @overload
1285 def __init__(self, target: expr, iter: expr, ifs: list[expr], is_async: int) -> None: ...
1286 @overload
1287 def __init__(self, target: expr, iter: expr, ifs: list[expr] = ..., *, is_async: int) -> None: ...
1288 else:
1289 def __init__(self, target: expr, iter: expr, ifs: list[expr], is_async: int) -> None: ...
1290
1291 if sys.version_info >= (3, 14):
1292 def __replace__(self, *, target: expr = ..., iter: expr = ..., ifs: list[expr] = ..., is_async: int = ...) -> Self: ...
1293
1294 class excepthandler(AST):
1295 lineno: int
1296 col_offset: int
1297 end_lineno: int | None
1298 end_col_offset: int | None
1299 def __init__(self, **kwargs: Unpack[_Attributes]) -> None: ...
1300
1301 if sys.version_info >= (3, 14):
1302 def __replace__(
1303 self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int | None = ..., end_col_offset: int | None = ...
1304 ) -> Self: ...
1305
1306 class ExceptHandler(excepthandler):
1307 if sys.version_info >= (3, 10):
1308 __match_args__ = ("type", "name", "body")
1309 type: expr | None
1310 name: str | None
1311 body: list[stmt]
1312 if sys.version_info >= (3, 13):
1313 def __init__(
1314 self, type: expr | None = None, name: str | None = None, body: list[stmt] = ..., **kwargs: Unpack[_Attributes]
1315 ) -> None: ...
1316 else:
1317 @overload
1318 def __init__(self, type: expr | None, name: str | None, body: list[stmt], **kwargs: Unpack[_Attributes]) -> None: ...
1319 @overload
1320 def __init__(
1321 self, type: expr | None = None, name: str | None = None, *, body: list[stmt], **kwargs: Unpack[_Attributes]
1322 ) -> None: ...
1323
1324 if sys.version_info >= (3, 14):
1325 def __replace__(
1326 self, *, type: expr | None = ..., name: str | None = ..., body: list[stmt] = ..., **kwargs: Unpack[_Attributes]
1327 ) -> Self: ...
1328
1329 class arguments(AST):
1330 if sys.version_info >= (3, 10):
1331 __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")
1332 posonlyargs: list[arg]
1333 args: list[arg]
1334 vararg: arg | None
1335 kwonlyargs: list[arg]
1336 kw_defaults: list[expr | None]
1337 kwarg: arg | None
1338 defaults: list[expr]
1339 if sys.version_info >= (3, 13):
1340 def __init__(
1341 self,
1342 posonlyargs: list[arg] = ...,
1343 args: list[arg] = ...,
1344 vararg: arg | None = None,
1345 kwonlyargs: list[arg] = ...,
1346 kw_defaults: list[expr | None] = ...,
1347 kwarg: arg | None = None,
1348 defaults: list[expr] = ...,
1349 ) -> None: ...
1350 else:
1351 @overload
1352 def __init__(
1353 self,
1354 posonlyargs: list[arg],
1355 args: list[arg],
1356 vararg: arg | None,
1357 kwonlyargs: list[arg],
1358 kw_defaults: list[expr | None],
1359 kwarg: arg | None,
1360 defaults: list[expr],
1361 ) -> None: ...
1362 @overload
1363 def __init__(
1364 self,
1365 posonlyargs: list[arg],
1366 args: list[arg],
1367 vararg: arg | None,
1368 kwonlyargs: list[arg],
1369 kw_defaults: list[expr | None],
1370 kwarg: arg | None = None,
1371 *,
1372 defaults: list[expr],
1373 ) -> None: ...
1374 @overload
1375 def __init__(
1376 self,
1377 posonlyargs: list[arg],
1378 args: list[arg],
1379 vararg: arg | None = None,
1380 *,
1381 kwonlyargs: list[arg],
1382 kw_defaults: list[expr | None],
1383 kwarg: arg | None = None,
1384 defaults: list[expr],
1385 ) -> None: ...
1386
1387 if sys.version_info >= (3, 14):
1388 def __replace__(
1389 self,
1390 *,
1391 posonlyargs: list[arg] = ...,
1392 args: list[arg] = ...,
1393 vararg: arg | None = ...,
1394 kwonlyargs: list[arg] = ...,
1395 kw_defaults: list[expr | None] = ...,
1396 kwarg: arg | None = ...,
1397 defaults: list[expr] = ...,
1398 ) -> Self: ...
1399
1400 class arg(AST):
1401 lineno: int
1402 col_offset: int
1403 end_lineno: int | None
1404 end_col_offset: int | None
1405 if sys.version_info >= (3, 10):
1406 __match_args__ = ("arg", "annotation", "type_comment")
1407 arg: str
1408 annotation: expr | None
1409 type_comment: str | None
1410 def __init__(
1411 self, arg: str, annotation: expr | None = None, type_comment: str | None = None, **kwargs: Unpack[_Attributes]
1412 ) -> None: ...
1413
1414 if sys.version_info >= (3, 14):
1415 def __replace__(
1416 self, *, arg: str = ..., annotation: expr | None = ..., type_comment: str | None = ..., **kwargs: Unpack[_Attributes]
1417 ) -> Self: ...
1418
1419 class keyword(AST):
1420 lineno: int
1421 col_offset: int
1422 end_lineno: int | None
1423 end_col_offset: int | None
1424 if sys.version_info >= (3, 10):
1425 __match_args__ = ("arg", "value")
1426 arg: str | None
1427 value: expr
1428 @overload
1429 def __init__(self, arg: str | None, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
1430 @overload
1431 def __init__(self, arg: str | None = None, *, value: expr, **kwargs: Unpack[_Attributes]) -> None: ...
1432
1433 if sys.version_info >= (3, 14):
1434 def __replace__(self, *, arg: str | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1435
1436 class alias(AST):
1437 name: str
1438 asname: str | None
1439 if sys.version_info >= (3, 10):
1440 lineno: int
1441 col_offset: int
1442 end_lineno: int | None
1443 end_col_offset: int | None
1444 if sys.version_info >= (3, 10):
1445 __match_args__ = ("name", "asname")
1446 if sys.version_info >= (3, 10):
1447 def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
1448 else:
1449 def __init__(self, name: str, asname: str | None = None) -> None: ...
1450
1451 if sys.version_info >= (3, 14):
1452 def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
1453
1454 class withitem(AST):
1455 if sys.version_info >= (3, 10):
1456 __match_args__ = ("context_expr", "optional_vars")
1457 context_expr: expr
1458 optional_vars: expr | None
1459 def __init__(self, context_expr: expr, optional_vars: expr | None = None) -> None: ...
1460
1461 if sys.version_info >= (3, 14):
1462 def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ...
1463
1464 if sys.version_info >= (3, 10):
1465 class pattern(AST):
1466 lineno: int
1467 col_offset: int
1468 end_lineno: int
1469 end_col_offset: int
1470 def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1471
1472 if sys.version_info >= (3, 14):
1473 def __replace__(
1474 self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ...
1475 ) -> Self: ...
1476
1477 class match_case(AST):
1478 __match_args__ = ("pattern", "guard", "body")
1479 pattern: ast.pattern
1480 guard: expr | None
1481 body: list[stmt]
1482 if sys.version_info >= (3, 13):
1483 def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ...
1484 elif sys.version_info >= (3, 10):
1485 @overload
1486 def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ...
1487 @overload
1488 def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ...
1489
1490 if sys.version_info >= (3, 14):
1491 def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ...
1492
1493 class Match(stmt):
1494 __match_args__ = ("subject", "cases")
1495 subject: expr
1496 cases: list[match_case]
1497 if sys.version_info >= (3, 13):
1498 def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
1499 else:
1500 def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ...
1501
1502 if sys.version_info >= (3, 14):
1503 def __replace__(
1504 self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]
1505 ) -> Self: ...
1506
1507 class MatchValue(pattern):
1508 __match_args__ = ("value",)
1509 value: expr
1510 def __init__(self, value: expr, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1511
1512 if sys.version_info >= (3, 14):
1513 def __replace__(self, *, value: expr = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1514
1515 class MatchSingleton(pattern):
1516 __match_args__ = ("value",)
1517 value: bool | None
1518 def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1519
1520 if sys.version_info >= (3, 14):
1521 def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1522
1523 class MatchSequence(pattern):
1524 __match_args__ = ("patterns",)
1525 patterns: list[pattern]
1526 if sys.version_info >= (3, 13):
1527 def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ...
1528 else:
1529 def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ...
1530
1531 if sys.version_info >= (3, 14):
1532 def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1533
1534 class MatchMapping(pattern):
1535 __match_args__ = ("keys", "patterns", "rest")
1536 keys: list[expr]
1537 patterns: list[pattern]
1538 rest: str | None
1539 if sys.version_info >= (3, 13):
1540 def __init__(
1541 self,
1542 keys: list[expr] = ...,
1543 patterns: list[pattern] = ...,
1544 rest: str | None = None,
1545 **kwargs: Unpack[_Attributes[int]],
1546 ) -> None: ...
1547 else:
1548 def __init__(
1549 self, keys: list[expr], patterns: list[pattern], rest: str | None = None, **kwargs: Unpack[_Attributes[int]]
1550 ) -> None: ...
1551
1552 if sys.version_info >= (3, 14):
1553 def __replace__(
1554 self,
1555 *,
1556 keys: list[expr] = ...,
1557 patterns: list[pattern] = ...,
1558 rest: str | None = ...,
1559 **kwargs: Unpack[_Attributes[int]],
1560 ) -> Self: ...
1561
1562 class MatchClass(pattern):
1563 __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")
1564 cls: expr
1565 patterns: list[pattern]
1566 kwd_attrs: list[str]
1567 kwd_patterns: list[pattern]
1568 if sys.version_info >= (3, 13):
1569 def __init__(
1570 self,
1571 cls: expr,
1572 patterns: list[pattern] = ...,
1573 kwd_attrs: list[str] = ...,
1574 kwd_patterns: list[pattern] = ...,
1575 **kwargs: Unpack[_Attributes[int]],
1576 ) -> None: ...
1577 else:
1578 def __init__(
1579 self,
1580 cls: expr,
1581 patterns: list[pattern],
1582 kwd_attrs: list[str],
1583 kwd_patterns: list[pattern],
1584 **kwargs: Unpack[_Attributes[int]],
1585 ) -> None: ...
1586
1587 if sys.version_info >= (3, 14):
1588 def __replace__(
1589 self,
1590 *,
1591 cls: expr = ...,
1592 patterns: list[pattern] = ...,
1593 kwd_attrs: list[str] = ...,
1594 kwd_patterns: list[pattern] = ...,
1595 **kwargs: Unpack[_Attributes[int]],
1596 ) -> Self: ...
1597
1598 class MatchStar(pattern):
1599 __match_args__ = ("name",)
1600 name: str | None
1601 def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1602
1603 if sys.version_info >= (3, 14):
1604 def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1605
1606 class MatchAs(pattern):
1607 __match_args__ = ("pattern", "name")
1608 pattern: ast.pattern | None
1609 name: str | None
1610 def __init__(
1611 self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]]
1612 ) -> None: ...
1613
1614 if sys.version_info >= (3, 14):
1615 def __replace__(
1616 self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]]
1617 ) -> Self: ...
1618
1619 class MatchOr(pattern):
1620 __match_args__ = ("patterns",)
1621 patterns: list[pattern]
1622 if sys.version_info >= (3, 13):
1623 def __init__(self, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> None: ...
1624 else:
1625 def __init__(self, patterns: list[pattern], **kwargs: Unpack[_Attributes[int]]) -> None: ...
1626
1627 if sys.version_info >= (3, 14):
1628 def __replace__(self, *, patterns: list[pattern] = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1629
1630 class type_ignore(AST): ...
1631
1632 class TypeIgnore(type_ignore):
1633 if sys.version_info >= (3, 10):
1634 __match_args__ = ("lineno", "tag")
1635 lineno: int
1636 tag: str
1637 def __init__(self, lineno: int, tag: str) -> None: ...
1638
1639 if sys.version_info >= (3, 14):
1640 def __replace__(self, *, lineno: int = ..., tag: str = ...) -> Self: ...
1641
1642 if sys.version_info >= (3, 12):
1643 class type_param(AST):
1644 lineno: int
1645 col_offset: int
1646 end_lineno: int
1647 end_col_offset: int
1648 def __init__(self, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1649
1650 if sys.version_info >= (3, 14):
1651 def __replace__(self, **kwargs: Unpack[_Attributes[int]]) -> Self: ...
1652
1653 class TypeVar(type_param):
1654 if sys.version_info >= (3, 13):
1655 __match_args__ = ("name", "bound", "default_value")
1656 else:
1657 __match_args__ = ("name", "bound")
1658 name: str
1659 bound: expr | None
1660 if sys.version_info >= (3, 13):
1661 default_value: expr | None
1662 def __init__(
1663 self, name: str, bound: expr | None = None, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]
1664 ) -> None: ...
1665 else:
1666 def __init__(self, name: str, bound: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1667
1668 if sys.version_info >= (3, 14):
1669 def __replace__(
1670 self,
1671 *,
1672 name: str = ...,
1673 bound: expr | None = ...,
1674 default_value: expr | None = ...,
1675 **kwargs: Unpack[_Attributes[int]],
1676 ) -> Self: ...
1677
1678 class ParamSpec(type_param):
1679 if sys.version_info >= (3, 13):
1680 __match_args__ = ("name", "default_value")
1681 else:
1682 __match_args__ = ("name",)
1683 name: str
1684 if sys.version_info >= (3, 13):
1685 default_value: expr | None
1686 def __init__(self, name: str, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1687 else:
1688 def __init__(self, name: str, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1689
1690 if sys.version_info >= (3, 14):
1691 def __replace__(
1692 self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
1693 ) -> Self: ...
1694
1695 class TypeVarTuple(type_param):
1696 if sys.version_info >= (3, 13):
1697 __match_args__ = ("name", "default_value")
1698 else:
1699 __match_args__ = ("name",)
1700 name: str
1701 if sys.version_info >= (3, 13):
1702 default_value: expr | None
1703 def __init__(self, name: str, default_value: expr | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1704 else:
1705 def __init__(self, name: str, **kwargs: Unpack[_Attributes[int]]) -> None: ...
1706
1707 if sys.version_info >= (3, 14):
1708 def __replace__(
1709 self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
1710 ) -> Self: ...
1711
1712 if sys.version_info >= (3, 14):
1713 @type_check_only
1714 class _ABC(type):
1715 def __init__(cls, *args: Unused) -> None: ...
1716
1717 else:
1718 class _ABC(type):
1719 def __init__(cls, *args: Unused) -> None: ...
1720
1721 if sys.version_info < (3, 14):
1722 @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
1723 class Num(Constant, metaclass=_ABC):
1724 def __new__(cls, n: complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
1725
1726 @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
1727 class Str(Constant, metaclass=_ABC):
1728 def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
1729
1730 @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
1731 class Bytes(Constant, metaclass=_ABC):
1732 def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
1733
1734 @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
1735 class NameConstant(Constant, metaclass=_ABC):
1736 def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
1737
1738 @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
1739 class Ellipsis(Constant, metaclass=_ABC):
1740 def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
1741
1742 # everything below here is defined in ast.py
1743
1744 _T = _TypeVar("_T", bound=AST)
1745
1746 if sys.version_info >= (3, 13):
1747 @overload
1748 def parse(
1749 source: _T,
1750 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1751 mode: Literal["exec", "eval", "func_type", "single"] = "exec",
1752 *,
1753 type_comments: bool = False,
1754 feature_version: None | int | tuple[int, int] = None,
1755 optimize: Literal[-1, 0, 1, 2] = -1,
1756 ) -> _T: ...
1757 @overload
1758 def parse(
1759 source: str | ReadableBuffer,
1760 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1761 mode: Literal["exec"] = "exec",
1762 *,
1763 type_comments: bool = False,
1764 feature_version: None | int | tuple[int, int] = None,
1765 optimize: Literal[-1, 0, 1, 2] = -1,
1766 ) -> Module: ...
1767 @overload
1768 def parse(
1769 source: str | ReadableBuffer,
1770 filename: str | bytes | os.PathLike[Any],
1771 mode: Literal["eval"],
1772 *,
1773 type_comments: bool = False,
1774 feature_version: None | int | tuple[int, int] = None,
1775 optimize: Literal[-1, 0, 1, 2] = -1,
1776 ) -> Expression: ...
1777 @overload
1778 def parse(
1779 source: str | ReadableBuffer,
1780 filename: str | bytes | os.PathLike[Any],
1781 mode: Literal["func_type"],
1782 *,
1783 type_comments: bool = False,
1784 feature_version: None | int | tuple[int, int] = None,
1785 optimize: Literal[-1, 0, 1, 2] = -1,
1786 ) -> FunctionType: ...
1787 @overload
1788 def parse(
1789 source: str | ReadableBuffer,
1790 filename: str | bytes | os.PathLike[Any],
1791 mode: Literal["single"],
1792 *,
1793 type_comments: bool = False,
1794 feature_version: None | int | tuple[int, int] = None,
1795 optimize: Literal[-1, 0, 1, 2] = -1,
1796 ) -> Interactive: ...
1797 @overload
1798 def parse(
1799 source: str | ReadableBuffer,
1800 *,
1801 mode: Literal["eval"],
1802 type_comments: bool = False,
1803 feature_version: None | int | tuple[int, int] = None,
1804 optimize: Literal[-1, 0, 1, 2] = -1,
1805 ) -> Expression: ...
1806 @overload
1807 def parse(
1808 source: str | ReadableBuffer,
1809 *,
1810 mode: Literal["func_type"],
1811 type_comments: bool = False,
1812 feature_version: None | int | tuple[int, int] = None,
1813 optimize: Literal[-1, 0, 1, 2] = -1,
1814 ) -> FunctionType: ...
1815 @overload
1816 def parse(
1817 source: str | ReadableBuffer,
1818 *,
1819 mode: Literal["single"],
1820 type_comments: bool = False,
1821 feature_version: None | int | tuple[int, int] = None,
1822 optimize: Literal[-1, 0, 1, 2] = -1,
1823 ) -> Interactive: ...
1824 @overload
1825 def parse(
1826 source: str | ReadableBuffer,
1827 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1828 mode: str = "exec",
1829 *,
1830 type_comments: bool = False,
1831 feature_version: None | int | tuple[int, int] = None,
1832 optimize: Literal[-1, 0, 1, 2] = -1,
1833 ) -> mod: ...
1834
1835 else:
1836 @overload
1837 def parse(
1838 source: _T,
1839 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1840 mode: Literal["exec", "eval", "func_type", "single"] = "exec",
1841 *,
1842 type_comments: bool = False,
1843 feature_version: None | int | tuple[int, int] = None,
1844 ) -> _T: ...
1845 @overload
1846 def parse(
1847 source: str | ReadableBuffer,
1848 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1849 mode: Literal["exec"] = "exec",
1850 *,
1851 type_comments: bool = False,
1852 feature_version: None | int | tuple[int, int] = None,
1853 ) -> Module: ...
1854 @overload
1855 def parse(
1856 source: str | ReadableBuffer,
1857 filename: str | bytes | os.PathLike[Any],
1858 mode: Literal["eval"],
1859 *,
1860 type_comments: bool = False,
1861 feature_version: None | int | tuple[int, int] = None,
1862 ) -> Expression: ...
1863 @overload
1864 def parse(
1865 source: str | ReadableBuffer,
1866 filename: str | bytes | os.PathLike[Any],
1867 mode: Literal["func_type"],
1868 *,
1869 type_comments: bool = False,
1870 feature_version: None | int | tuple[int, int] = None,
1871 ) -> FunctionType: ...
1872 @overload
1873 def parse(
1874 source: str | ReadableBuffer,
1875 filename: str | bytes | os.PathLike[Any],
1876 mode: Literal["single"],
1877 *,
1878 type_comments: bool = False,
1879 feature_version: None | int | tuple[int, int] = None,
1880 ) -> Interactive: ...
1881 @overload
1882 def parse(
1883 source: str | ReadableBuffer,
1884 *,
1885 mode: Literal["eval"],
1886 type_comments: bool = False,
1887 feature_version: None | int | tuple[int, int] = None,
1888 ) -> Expression: ...
1889 @overload
1890 def parse(
1891 source: str | ReadableBuffer,
1892 *,
1893 mode: Literal["func_type"],
1894 type_comments: bool = False,
1895 feature_version: None | int | tuple[int, int] = None,
1896 ) -> FunctionType: ...
1897 @overload
1898 def parse(
1899 source: str | ReadableBuffer,
1900 *,
1901 mode: Literal["single"],
1902 type_comments: bool = False,
1903 feature_version: None | int | tuple[int, int] = None,
1904 ) -> Interactive: ...
1905 @overload
1906 def parse(
1907 source: str | ReadableBuffer,
1908 filename: str | bytes | os.PathLike[Any] = "<unknown>",
1909 mode: str = "exec",
1910 *,
1911 type_comments: bool = False,
1912 feature_version: None | int | tuple[int, int] = None,
1913 ) -> mod: ...
1914
1915 def literal_eval(node_or_string: str | AST) -> Any: ...
1916
1917 if sys.version_info >= (3, 13):
1918 def dump(
1919 node: AST,
1920 annotate_fields: bool = True,
1921 include_attributes: bool = False,
1922 *,
1923 indent: int | str | None = None,
1924 show_empty: bool = False,
1925 ) -> str: ...
1926
1927 else:
1928 def dump(
1929 node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
1930 ) -> str: ...
1931
1932 def copy_location(new_node: _T, old_node: AST) -> _T: ...
1933 def fix_missing_locations(node: _T) -> _T: ...
1934 def increment_lineno(node: _T, n: int = 1) -> _T: ...
1935 def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ...
1936 def iter_child_nodes(node: AST) -> Iterator[AST]: ...
1937 def get_docstring(node: AsyncFunctionDef | FunctionDef | ClassDef | Module, clean: bool = True) -> str | None: ...
1938 def get_source_segment(source: str, node: AST, *, padded: bool = False) -> str | None: ...
1939 def walk(node: AST) -> Iterator[AST]: ...
1940
1941 if sys.version_info >= (3, 14):
1942 def compare(left: AST, right: AST, /, *, compare_attributes: bool = False) -> bool: ...
1943
1944 class NodeVisitor:
1945 # All visit methods below can be overwritten by subclasses and return an
1946 # arbitrary value, which is passed to the caller.
1947 def visit(self, node: AST) -> Any: ...
1948 def generic_visit(self, node: AST) -> Any: ...
1949 # The following visit methods are not defined on NodeVisitor, but can
1950 # be implemented by subclasses and are called during a visit if defined.
1951 def visit_Module(self, node: Module) -> Any: ...
1952 def visit_Interactive(self, node: Interactive) -> Any: ...
1953 def visit_Expression(self, node: Expression) -> Any: ...
1954 def visit_FunctionDef(self, node: FunctionDef) -> Any: ...
1955 def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> Any: ...
1956 def visit_ClassDef(self, node: ClassDef) -> Any: ...
1957 def visit_Return(self, node: Return) -> Any: ...
1958 def visit_Delete(self, node: Delete) -> Any: ...
1959 def visit_Assign(self, node: Assign) -> Any: ...
1960 def visit_AugAssign(self, node: AugAssign) -> Any: ...
1961 def visit_AnnAssign(self, node: AnnAssign) -> Any: ...
1962 def visit_For(self, node: For) -> Any: ...
1963 def visit_AsyncFor(self, node: AsyncFor) -> Any: ...
1964 def visit_While(self, node: While) -> Any: ...
1965 def visit_If(self, node: If) -> Any: ...
1966 def visit_With(self, node: With) -> Any: ...
1967 def visit_AsyncWith(self, node: AsyncWith) -> Any: ...
1968 def visit_Raise(self, node: Raise) -> Any: ...
1969 def visit_Try(self, node: Try) -> Any: ...
1970 def visit_Assert(self, node: Assert) -> Any: ...
1971 def visit_Import(self, node: Import) -> Any: ...
1972 def visit_ImportFrom(self, node: ImportFrom) -> Any: ...
1973 def visit_Global(self, node: Global) -> Any: ...
1974 def visit_Nonlocal(self, node: Nonlocal) -> Any: ...
1975 def visit_Expr(self, node: Expr) -> Any: ...
1976 def visit_Pass(self, node: Pass) -> Any: ...
1977 def visit_Break(self, node: Break) -> Any: ...
1978 def visit_Continue(self, node: Continue) -> Any: ...
1979 def visit_Slice(self, node: Slice) -> Any: ...
1980 def visit_BoolOp(self, node: BoolOp) -> Any: ...
1981 def visit_BinOp(self, node: BinOp) -> Any: ...
1982 def visit_UnaryOp(self, node: UnaryOp) -> Any: ...
1983 def visit_Lambda(self, node: Lambda) -> Any: ...
1984 def visit_IfExp(self, node: IfExp) -> Any: ...
1985 def visit_Dict(self, node: Dict) -> Any: ...
1986 def visit_Set(self, node: Set) -> Any: ...
1987 def visit_ListComp(self, node: ListComp) -> Any: ...
1988 def visit_SetComp(self, node: SetComp) -> Any: ...
1989 def visit_DictComp(self, node: DictComp) -> Any: ...
1990 def visit_GeneratorExp(self, node: GeneratorExp) -> Any: ...
1991 def visit_Await(self, node: Await) -> Any: ...
1992 def visit_Yield(self, node: Yield) -> Any: ...
1993 def visit_YieldFrom(self, node: YieldFrom) -> Any: ...
1994 def visit_Compare(self, node: Compare) -> Any: ...
1995 def visit_Call(self, node: Call) -> Any: ...
1996 def visit_FormattedValue(self, node: FormattedValue) -> Any: ...
1997 def visit_JoinedStr(self, node: JoinedStr) -> Any: ...
1998 def visit_Constant(self, node: Constant) -> Any: ...
1999 def visit_NamedExpr(self, node: NamedExpr) -> Any: ...
2000 def visit_TypeIgnore(self, node: TypeIgnore) -> Any: ...
2001 def visit_Attribute(self, node: Attribute) -> Any: ...
2002 def visit_Subscript(self, node: Subscript) -> Any: ...
2003 def visit_Starred(self, node: Starred) -> Any: ...
2004 def visit_Name(self, node: Name) -> Any: ...
2005 def visit_List(self, node: List) -> Any: ...
2006 def visit_Tuple(self, node: Tuple) -> Any: ...
2007 def visit_Del(self, node: Del) -> Any: ...
2008 def visit_Load(self, node: Load) -> Any: ...
2009 def visit_Store(self, node: Store) -> Any: ...
2010 def visit_And(self, node: And) -> Any: ...
2011 def visit_Or(self, node: Or) -> Any: ...
2012 def visit_Add(self, node: Add) -> Any: ...
2013 def visit_BitAnd(self, node: BitAnd) -> Any: ...
2014 def visit_BitOr(self, node: BitOr) -> Any: ...
2015 def visit_BitXor(self, node: BitXor) -> Any: ...
2016 def visit_Div(self, node: Div) -> Any: ...
2017 def visit_FloorDiv(self, node: FloorDiv) -> Any: ...
2018 def visit_LShift(self, node: LShift) -> Any: ...
2019 def visit_Mod(self, node: Mod) -> Any: ...
2020 def visit_Mult(self, node: Mult) -> Any: ...
2021 def visit_MatMult(self, node: MatMult) -> Any: ...
2022 def visit_Pow(self, node: Pow) -> Any: ...
2023 def visit_RShift(self, node: RShift) -> Any: ...
2024 def visit_Sub(self, node: Sub) -> Any: ...
2025 def visit_Invert(self, node: Invert) -> Any: ...
2026 def visit_Not(self, node: Not) -> Any: ...
2027 def visit_UAdd(self, node: UAdd) -> Any: ...
2028 def visit_USub(self, node: USub) -> Any: ...
2029 def visit_Eq(self, node: Eq) -> Any: ...
2030 def visit_Gt(self, node: Gt) -> Any: ...
2031 def visit_GtE(self, node: GtE) -> Any: ...
2032 def visit_In(self, node: In) -> Any: ...
2033 def visit_Is(self, node: Is) -> Any: ...
2034 def visit_IsNot(self, node: IsNot) -> Any: ...
2035 def visit_Lt(self, node: Lt) -> Any: ...
2036 def visit_LtE(self, node: LtE) -> Any: ...
2037 def visit_NotEq(self, node: NotEq) -> Any: ...
2038 def visit_NotIn(self, node: NotIn) -> Any: ...
2039 def visit_comprehension(self, node: comprehension) -> Any: ...
2040 def visit_ExceptHandler(self, node: ExceptHandler) -> Any: ...
2041 def visit_arguments(self, node: arguments) -> Any: ...
2042 def visit_arg(self, node: arg) -> Any: ...
2043 def visit_keyword(self, node: keyword) -> Any: ...
2044 def visit_alias(self, node: alias) -> Any: ...
2045 def visit_withitem(self, node: withitem) -> Any: ...
2046 if sys.version_info >= (3, 10):
2047 def visit_Match(self, node: Match) -> Any: ...
2048 def visit_match_case(self, node: match_case) -> Any: ...
2049 def visit_MatchValue(self, node: MatchValue) -> Any: ...
2050 def visit_MatchSequence(self, node: MatchSequence) -> Any: ...
2051 def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ...
2052 def visit_MatchStar(self, node: MatchStar) -> Any: ...
2053 def visit_MatchMapping(self, node: MatchMapping) -> Any: ...
2054 def visit_MatchClass(self, node: MatchClass) -> Any: ...
2055 def visit_MatchAs(self, node: MatchAs) -> Any: ...
2056 def visit_MatchOr(self, node: MatchOr) -> Any: ...
2057
2058 if sys.version_info >= (3, 11):
2059 def visit_TryStar(self, node: TryStar) -> Any: ...
2060
2061 if sys.version_info >= (3, 12):
2062 def visit_TypeVar(self, node: TypeVar) -> Any: ...
2063 def visit_ParamSpec(self, node: ParamSpec) -> Any: ...
2064 def visit_TypeVarTuple(self, node: TypeVarTuple) -> Any: ...
2065 def visit_TypeAlias(self, node: TypeAlias) -> Any: ...
2066
2067 # visit methods for deprecated nodes
2068 def visit_ExtSlice(self, node: ExtSlice) -> Any: ...
2069 def visit_Index(self, node: Index) -> Any: ...
2070 def visit_Suite(self, node: Suite) -> Any: ...
2071 def visit_AugLoad(self, node: AugLoad) -> Any: ...
2072 def visit_AugStore(self, node: AugStore) -> Any: ...
2073 def visit_Param(self, node: Param) -> Any: ...
2074
2075 if sys.version_info < (3, 14):
2076 @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
2077 def visit_Num(self, node: Num) -> Any: ... # type: ignore[deprecated]
2078 @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
2079 def visit_Str(self, node: Str) -> Any: ... # type: ignore[deprecated]
2080 @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
2081 def visit_Bytes(self, node: Bytes) -> Any: ... # type: ignore[deprecated]
2082 @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
2083 def visit_NameConstant(self, node: NameConstant) -> Any: ... # type: ignore[deprecated]
2084 @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
2085 def visit_Ellipsis(self, node: Ellipsis) -> Any: ... # type: ignore[deprecated]
2086
2087 class NodeTransformer(NodeVisitor):
2088 def generic_visit(self, node: AST) -> AST: ...
2089 # TODO: Override the visit_* methods with better return types.
2090 # The usual return type is AST | None, but Iterable[AST]
2091 # is also allowed in some cases -- this needs to be mapped.
2092
2093 def unparse(ast_obj: AST) -> str: ...
2094
2095 if sys.version_info >= (3, 14):
2096 def main(args: Sequence[str] | None = None) -> None: ...
2097
2098 else:
2099 def main() -> None: ...