Skip to content

Commit 55cceba

Browse files
author
hauntsaninja
committed
Fix crashes with unpacking SyntaxError
In general, mypy doesn't promise to be able to check the remainder of your code in the presence of syntax errors, so just make this a blocking error. Fixes python#9137 Fixes python#3825 (most of the reports in this issue were fixed by python#8827)
1 parent dda64db commit 55cceba

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mypy/semanal.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3719,8 +3719,7 @@ def visit_dict_expr(self, expr: DictExpr) -> None:
37193719

37203720
def visit_star_expr(self, expr: StarExpr) -> None:
37213721
if not expr.valid:
3722-
# XXX TODO Change this error message
3723-
self.fail('Can use starred expression only as assignment target', expr)
3722+
self.fail('Can use starred expression only as assignment target', expr, blocker=True)
37243723
else:
37253724
expr.expr.accept(self)
37263725

test-data/unit/check-tuples.test

+4
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,10 @@ b = (1, 'x')
10021002
a = (0, *b, '')
10031003
[builtins fixtures/tuple.pyi]
10041004

1005+
[case testUnpackSyntaxError]
1006+
*foo # E: Can use starred expression only as assignment target
1007+
[builtins fixtures/tuple.pyi]
1008+
10051009
[case testTupleMeetTupleAny]
10061010
from typing import Union, Tuple
10071011
class A: pass

0 commit comments

Comments
 (0)