Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update starred expression error inline with Python #16304

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
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