AnnAssign

class astroid.nodes.AnnAssign(lineno: int | None, col_offset: int | None, parent: NodeNG | None, *, end_lineno: int | None, end_col_offset: int | None)[source]

Bases: AssignTypeNode, Statement

Class representing an ast.AnnAssign node.

An AnnAssign is an assignment with a type annotation.

>>> import astroid
>>> node = astroid.extract_node('variable: List[int] = range(10)')
>>> node
<AnnAssign l.1 at 0x7effe1d4c630>
annotation: NodeNG

The type annotation of what is being assigned to.

assigned_stmts(node: node_classes.AssignedStmtsPossibleNode = None, context: InferenceContext | None = None, assign_path: list[int] | None = None) Any

Returns the assigned statement (non inferred) according to the assignment type. See astroid/protocols.py for actual implementation.

get_children()[source]

Get the child nodes below this node.

postinit(target: Name | Attribute | Subscript, annotation: NodeNG, simple: int, value: NodeNG | None) None[source]
simple: int

Whether target is a pure name or a complex statement.

target: Name | Attribute | Subscript

What is being assigned to.

value: NodeNG | None

The value being assigned to the variables.