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

Method analyze_tuple_or_list_lvalue

mypy/semanal.py:4602–4620  ·  view source on GitHub ↗

Analyze an lvalue or assignment target that is a list or tuple.

(self, lval: TupleExpr, explicit_type: bool = False)

Source from the content-addressed store, hash-verified

4600 func.def_or_infer_vars = True
4601
4602 def analyze_tuple_or_list_lvalue(self, lval: TupleExpr, explicit_type: bool = False) -> None:
4603 """Analyze an lvalue or assignment target that is a list or tuple."""
4604 items = lval.items
4605 star_exprs = [item for item in items if isinstance(item, StarExpr)]
4606
4607 if len(star_exprs) > 1:
4608 self.fail("Two starred expressions in assignment", lval)
4609 else:
4610 if len(star_exprs) == 1:
4611 star_exprs[0].valid = True
4612 for i in items:
4613 self.analyze_lvalue(
4614 lval=i,
4615 nested=True,
4616 explicit_type=explicit_type,
4617 # Lists and tuples always have explicit values defined:
4618 # `a, b, c = value`
4619 has_explicit_value=True,
4620 )
4621
4622 def analyze_member_lvalue(
4623 self, lval: MemberExpr, explicit_type: bool, is_final: bool, has_explicit_value: bool

Callers 1

analyze_lvalueMethod · 0.95

Calls 4

failMethod · 0.95
analyze_lvalueMethod · 0.95
isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected