MCPcopy Create free account
hub / github.com/python/mypy / _parse_assignments

Function _parse_assignments

mypy/plugins/attrs.py:804–818  ·  view source on GitHub ↗

Convert a possibly complex assignment expression into lists of lvalues and rvalues.

(
    lvalue: Expression, stmt: AssignmentStmt
)

Source from the content-addressed store, hash-verified

802
803
804def _parse_assignments(
805 lvalue: Expression, stmt: AssignmentStmt
806) -> tuple[list[NameExpr], list[Expression]]:
807 """Convert a possibly complex assignment expression into lists of lvalues and rvalues."""
808 lvalues: list[NameExpr] = []
809 rvalues: list[Expression] = []
810 if isinstance(lvalue, (TupleExpr, ListExpr)):
811 if all(isinstance(item, NameExpr) for item in lvalue.items):
812 lvalues = cast(list[NameExpr], lvalue.items)
813 if isinstance(stmt.rvalue, (TupleExpr, ListExpr)):
814 rvalues = stmt.rvalue.items
815 elif isinstance(lvalue, NameExpr):
816 lvalues = [lvalue]
817 rvalues = [stmt.rvalue]
818 return lvalues, rvalues
819
820
821def _add_order(ctx: mypy.plugin.ClassDefContext, adder: MethodAdder) -> None:

Callers 2

_detect_auto_attribsFunction · 0.85

Calls 2

isinstanceFunction · 0.85
allFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…