Skip to content

Commit

Permalink
Update starred expression error inline with Python
Browse files Browse the repository at this point in the history
  • Loading branch information
cibinmathew committed Oct 21, 2023
1 parent a3af87b commit 5516128
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4997,7 +4997,7 @@ def visit_dict_expr(self, expr: DictExpr) -> None:

def visit_star_expr(self, expr: StarExpr) -> None:
if not expr.valid:
self.fail("Can use starred expression only as assignment target", expr, blocker=True)
self.fail("can't use starred expression here", expr, blocker=True)
else:
expr.expr.accept(self)

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -2232,7 +2232,7 @@ def foo(x: int) -> Union[Generator[A, None, None], Generator[B, None, None]]:
yield x # E: Incompatible types in "yield" (actual type "int", expected type "Union[A, B]")

[case testNoCrashOnStarRightHandSide]
x = *(1, 2, 3) # E: Can use starred expression only as assignment target
x = *(1, 2, 3) # E: can't use starred expression here
[builtins fixtures/tuple.pyi]


Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-tuples.test
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ a = (0, *b, '')
[builtins fixtures/tuple.pyi]

[case testUnpackSyntaxError]
*foo # E: Can use starred expression only as assignment target
*foo # E: can't use starred expression here
[builtins fixtures/tuple.pyi]

[case testUnpackBases]
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/semanal-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,13 @@ c = 1
d = 1
a = *b
[out]
main:4: error: Can use starred expression only as assignment target
main:4: error: can't use starred expression here

[case testStarExpressionInExp]
a = 1
*a + 1
[out]
main:2: error: Can use starred expression only as assignment target
main:2: error: can't use starred expression here

[case testInvalidDel1]
x = 1
Expand Down

0 comments on commit 5516128

Please sign in to comment.