AssignAttr¶
- class astroid.nodes.AssignAttr(attrname: str, lineno: int, col_offset: int, parent: NodeNG, *, end_lineno: int | None, end_col_offset: int | None)[source]¶
Bases:
LookupMixIn
,ParentAssignNode
Variation of
ast.Assign
representing assignment to an attribute.>>> import astroid >>> node = astroid.extract_node('self.attribute = range(10)') >>> node <Assign l.1 at 0x7effe1d521d0> >>> list(node.get_children()) [<AssignAttr.attribute l.1 at 0x7effe1d52320>, <Call l.1 at 0x7effe1d522e8>] >>> list(node.get_children())[0].as_string() 'self.attribute'
- 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.
- attrname¶
The name of the attribute being assigned to.
- infer_lhs(**kwargs: _P.kwargs) Generator[InferenceResult] ¶