module documentation

Abstract syntax tree node classes (i.e. parse tree).

Class ArgKind Undocumented
Class Argument A single argument in a FuncItem.
Class AssertStmt Undocumented
Class AssertTypeExpr Represents a typing.assert_type(expr, type) call.
Class AssignmentExpr Assignment expressions in Python 3.8+, like "a := 2".
Class AssignmentStmt Assignment statement.
Class AwaitExpr Await expression (await ...).
Class Block Undocumented
Class BreakStmt Undocumented
Class BytesExpr Bytes literal
Class CallExpr Call expression.
Class CastExpr Cast expression cast(type, expr).
Class ClassDef Class definition
Class ComparisonExpr Comparison expression (e.g. a < b > c < d).
Class ComplexExpr Complex literal
Class ConditionalExpr Conditional expression (e.g. x if y else z)
Class Context Base type for objects that are valid as error message locations.
Class ContinueStmt Undocumented
Class DataclassTransformSpec Specifies how a dataclass-like transform should be applied. The fields here are based on the parameters accepted by `typing.dataclass_transform`.
Class Decorator A decorated function.
Class DelStmt Undocumented
Class DictExpr Dictionary literal expression {key: value, ...}.
Class DictionaryComprehension Dictionary comprehension (e.g. {k: v for k, v in a}
Class EllipsisExpr Ellipsis (...)
Class EnumCallExpr Named tuple expression Enum('name', 'val1 val2 ...').
Class Expression An expression node.
Class ExpressionStmt An expression as a statement, such as print(s).
Class FakeExpression A dummy expression.
Class FakeInfo Undocumented
Class FloatExpr Float literal
Class ForStmt Undocumented
Class FuncBase Abstract base class for function-like nodes.
Class FuncDef Function definition.
Class FuncItem Base class for nodes usable as overloaded function items.
Class GeneratorExpr Generator expression ... for ... in ... [ for ... in ... ] [ if ... ].
Class GlobalDecl Declaration global x, y, ...
Class IfStmt Undocumented
Class Import import m [as n]
Class ImportAll from m import *
Class ImportBase Base class for all import statements.
Class ImportFrom from m import x [as y], ...
Class IndexExpr Index expression x[y].
Class IntExpr Integer literal
Class LambdaExpr Lambda expression
Class ListComprehension List comprehension (e.g. [x + 1 for x in a])
Class ListExpr List literal expression [...].
Class MatchStmt Undocumented
Class MemberExpr Member access expression x.y
Class MypyFile The abstract syntax tree of a single source file.
Class NamedTupleExpr Named tuple expression namedtuple(...) or NamedTuple(...).
Class NameExpr Name expression
Class NewTypeExpr NewType expression NewType(...).
Class Node Common base class for all non-type parse tree nodes.
Class NonlocalDecl Declaration nonlocal x, y, ...
Class OperatorAssignmentStmt Operator assignment statement such as x += 1
Class OpExpr Binary operation.
Class OverloadedFuncDef A logical node representing all the variants of a multi-declaration function.
Class ParamSpecExpr Undocumented
Class PassStmt Undocumented
Class PlaceholderNode Temporary symbol node that will later become a real SymbolNode.
Class PromoteExpr Ducktype class decorator expression _promote(...).
Class RaiseStmt Undocumented
Class RefExpr Abstract base class for name-like constructs
Class ReturnStmt Undocumented
Class RevealExpr Reveal type expression reveal_type(expr) or reveal_locals() expression.
Class SetComprehension Set comprehension (e.g. {x + 1 for x in a})
Class SetExpr Set literal expression {value, ...}.
Class SliceExpr Slice expression (e.g. 'x:y', 'x:', '::2' or ':').
Class StarExpr Star expression
Class Statement A statement node.
Class StrExpr String literal
Class SuperExpr Expression super().name
Class SymbolNode Nodes that can be stored in a symbol table.
Class SymbolTable Static representation of a namespace dictionary.
Class SymbolTableNode Description of a name binding in a symbol table.
Class TempNode Temporary dummy node used during type checking.
Class TryStmt Undocumented
Class TupleExpr Tuple literal expression (..., ...)
Class TypeAlias A symbol node representing a type alias.
Class TypeAliasExpr Type alias expression (rvalue).
Class TypeApplication Type application expr[type, ...]
Class TypedDictExpr Typed dict expression TypedDict(...).
Class TypeInfo The type structure of a single class.
Class TypeVarExpr Type variable expression TypeVar(...).
Class TypeVarLikeExpr Base class for TypeVarExpr, ParamSpecExpr and TypeVarTupleExpr.
Class TypeVarTupleExpr Type variable tuple expression TypeVarTuple(...).
Class UnaryExpr Unary operation
Class Var A variable.
Class WhileStmt Undocumented
Class WithStmt Undocumented
Class YieldExpr Undocumented
Class YieldFromExpr Undocumented
Function check_arg_kinds Undocumented
Function check_arg_names Undocumented
Function get_flags Undocumented
Function get_member_expr_fullname Return the qualified name representation of a member expression.
Function get_nongen_builtins Undocumented
Function is_class_var Return whether the expression is ClassVar[...]
Function is_final_node Check whether `node` corresponds to a final attribute.
Function local_definitions Iterate over local definitions (not imported) in a symbol table.
Function set_flags Undocumented
Constant CLASSDEF_NO_INFO Undocumented
Constant CONTRAVARIANT Undocumented
Constant COVARIANT Undocumented
Constant deserialize_map Undocumented
Constant FUNC_NO_INFO Undocumented
Constant FUNCBASE_FLAGS Undocumented
Constant FUNCDEF_FLAGS Undocumented
Constant FUNCITEM_FLAGS Undocumented
Constant GDEF Undocumented
Constant implicit_module_attrs Undocumented
Constant IMPLICITLY_ABSTRACT Undocumented
Constant INVARIANT Undocumented
Constant inverse_node_kinds Undocumented
Constant IS_ABSTRACT Undocumented
Constant LDEF Undocumented
Constant LITERAL_NO Undocumented
Constant LITERAL_TYPE Undocumented
Constant LITERAL_YES Undocumented
Constant MDEF Undocumented
Constant node_kinds Undocumented
Constant NOT_ABSTRACT Undocumented
Constant REVEAL_LOCALS Undocumented
Constant REVEAL_TYPE Undocumented
Constant reverse_builtin_aliases Undocumented
Constant RUNTIME_PROTOCOL_DECOS Undocumented
Constant SYMBOL_FUNCBASE_TYPES Undocumented
Constant type_aliases Undocumented
Constant type_aliases_source_versions Undocumented
Constant typing_extensions_aliases Undocumented
Constant UNBOUND_IMPORTED Undocumented
Constant VAR_FLAGS Undocumented
Constant VAR_NO_INFO Undocumented
Type Variable T Undocumented
Type Alias Definition Undocumented
Type Alias JsonDict Undocumented
Type Alias OverloadPart Undocumented
Constant _nongen_builtins Undocumented
def check_arg_kinds(arg_kinds: list[ArgKind], nodes: list[T], fail: Callable[[str, T], None]): (source)

Undocumented

def check_arg_names(names: Sequence[str|None], nodes: list[T], fail: Callable[[str, T], None], description: str = 'function definition'): (source)

Undocumented

def get_flags(node: Node, names: list[str]) -> list[str]: (source)

Undocumented

def get_member_expr_fullname(expr: MemberExpr) -> str|None: (source)

Return the qualified name representation of a member expression. Return a string of form foo.bar, foo.bar.baz, or similar, or None if the argument cannot be represented in this form.

def get_nongen_builtins(python_version: tuple[int, int]) -> dict[str, str]: (source)

Undocumented

def is_class_var(expr: NameExpr) -> bool: (source)

Return whether the expression is ClassVar[...]

def is_final_node(node: SymbolNode|None) -> bool: (source)

Check whether `node` corresponds to a final attribute.

def local_definitions(names: SymbolTable, name_prefix: str, info: TypeInfo|None = None) -> Iterator[Definition]: (source)

Iterate over local definitions (not imported) in a symbol table. Recursively iterate over class members and nested classes.

def set_flags(node: Node, flags: list[str]): (source)

Undocumented

CLASSDEF_NO_INFO: TypeInfo = (source)

Undocumented

Value
FakeInfo('ClassDef is lacking info')
CONTRAVARIANT: int = (source)

Undocumented

Value
2
COVARIANT: int = (source)

Undocumented

Value
1
deserialize_map = (source)

Undocumented

Value
{key: obj.deserialize for key, obj in globals().items() if type(obj) is not
    FakeInfo and isinstance(obj, type) and issubclass(obj, SymbolNode) and 
    obj is not SymbolNode}
FUNC_NO_INFO: TypeInfo = (source)

Undocumented

Value
FakeInfo('FuncBase for non-methods lack info')
FUNCBASE_FLAGS: list[str] = (source)

Undocumented

Value
['is_property', 'is_class', 'is_static', 'is_final']
FUNCDEF_FLAGS = (source)

Undocumented

Value
FUNCITEM_FLAGS+['is_decorated',
                'is_conditional',
                'is_trivial_body',
                'is_mypy_only']
FUNCITEM_FLAGS = (source)

Undocumented

Value
FUNCBASE_FLAGS+['is_overload',
                'is_generator',
                'is_coroutine',
                'is_async_generator',
                'is_awaitable_coroutine']

Undocumented

Value
1
implicit_module_attrs: dict = (source)

Undocumented

Value
{'__name__': '__builtins__.str',
 '__doc__': None,
 '__path__': None,
 '__file__': '__builtins__.str',
 '__package__': '__builtins__.str',
 '__annotations__': None}
IMPLICITLY_ABSTRACT: int = (source)

Undocumented

Value
2
INVARIANT: int = (source)

Undocumented

Value
0
inverse_node_kinds = (source)

Undocumented

Value
{_kind: _name for _name, _kind in node_kinds.items()}
IS_ABSTRACT: int = (source)

Undocumented

Value
1

Undocumented

Value
0
LITERAL_NO: int = (source)

Undocumented

Value
0
LITERAL_TYPE: int = (source)

Undocumented

Value
1
LITERAL_YES: int = (source)

Undocumented

Value
2

Undocumented

Value
2
node_kinds = (source)

Undocumented

Value
{LDEF: 'Ldef', GDEF: 'Gdef', MDEF: 'Mdef', UNBOUND_IMPORTED: 'UnboundImported'}
NOT_ABSTRACT: int = (source)

Undocumented

Value
0
REVEAL_LOCALS: int = (source)

Undocumented

Value
1
REVEAL_TYPE: int = (source)

Undocumented

Value
0
reverse_builtin_aliases: dict[str, str] = (source)

Undocumented

Value
{'builtins.list': 'typing.List',
 'builtins.dict': 'typing.Dict',
 'builtins.set': 'typing.Set',
 'builtins.frozenset': 'typing.FrozenSet'}
RUNTIME_PROTOCOL_DECOS: tuple[str, ...] = (source)

Undocumented

Value
('typing.runtime_checkable',
 'typing_extensions.runtime',
 'typing_extensions.runtime_checkable')
SYMBOL_FUNCBASE_TYPES = (source)

Undocumented

Value
(OverloadedFuncDef, FuncDef)
type_aliases: dict[str, str] = (source)

Undocumented

Value
{'typing.List': 'builtins.list',
 'typing.Dict': 'builtins.dict',
 'typing.Set': 'builtins.set',
 'typing.FrozenSet': 'builtins.frozenset',
 'typing.ChainMap': 'collections.ChainMap',
 'typing.Counter': 'collections.Counter',
 'typing.DefaultDict': 'collections.defaultdict',
...
type_aliases_source_versions: dict = (source)

Undocumented

Value
{'typing.List': (2, 7),
 'typing.Dict': (2, 7),
 'typing.Set': (2, 7),
 'typing.FrozenSet': (2, 7),
 'typing.ChainMap': (3, 3),
 'typing.Counter': (2, 7),
 'typing.DefaultDict': (2, 7),
...
typing_extensions_aliases: dict[str, str] = (source)

Undocumented

Value
{'typing_extensions.OrderedDict': 'collections.OrderedDict',
 'typing_extensions.LiteralString': 'builtins.str'}
UNBOUND_IMPORTED: int = (source)

Undocumented

Value
3
VAR_FLAGS: list[str] = (source)

Undocumented

Value
['is_self',
 'is_initialized_in_class',
 'is_staticmethod',
 'is_classmethod',
 'is_property',
 'is_settable_property',
 'is_suppressed_import',
...
VAR_NO_INFO: TypeInfo = (source)

Undocumented

Value
FakeInfo('Var is lacking info')

Undocumented

Value
TypeVar('T')
Definition: _TypeAlias = (source)

Undocumented

Value
Tuple[str, SymbolTableNode, Optional[TypeInfo]]
JsonDict: _TypeAlias = (source)

Undocumented

Value
Dict[str, Any]
OverloadPart: _TypeAlias = (source)

Undocumented

Value
Union[FuncDef, Decorator]
_nongen_builtins: dict[str, str] = (source)

Undocumented

Value
{'builtins.tuple': 'typing.Tuple', 'builtins.enumerate': ''}