Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8499,16 +8499,16 @@ def names_modified_by_assignment(s: AssignmentStmt) -> list[NameExpr]:
return result


def names_modified_in_lvalue(lvalue: Lvalue) -> list[NameExpr]:
def names_modified_in_lvalue(lvalue: Lvalue, include_star: bool = False) -> list[NameExpr]:
"""Return all NameExpr assignment targets in an Lvalue."""
if isinstance(lvalue, NameExpr):
return [lvalue]
elif isinstance(lvalue, StarExpr):
elif isinstance(lvalue, StarExpr) and include_star:
return names_modified_in_lvalue(lvalue.expr)
elif isinstance(lvalue, (ListExpr, TupleExpr)):
result: list[NameExpr] = []
for item in lvalue.items:
result += names_modified_in_lvalue(item)
result += names_modified_in_lvalue(item, include_star=True)
return result
return []

Expand Down
12 changes: 12 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -8293,3 +8293,15 @@ Jérôme = False
[stale]
[out]
[out2]

[case testInvalidUnpackTargetFromUndefinedNoCrash]
*a = b
a
[out]
main:1: error: Starred assignment target must be in a list or tuple
main:1: error: Name "b" is not defined
main:2: error: Name "a" is not defined
[out2]
main:1: error: Starred assignment target must be in a list or tuple
main:1: error: Name "b" is not defined
main:2: error: Name "a" is not defined
Loading