diff --git a/mypy/semanal.py b/mypy/semanal.py index 2ea444bf4ab26..ad70cc85a45d5 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -2636,9 +2636,6 @@ def analyze_lvalue(self, self.fail('Unexpected type declaration', lval) lval.accept(self) elif isinstance(lval, TupleExpr): - items = lval.items - if len(items) == 0 and isinstance(lval, TupleExpr): - self.fail("can't assign to ()", lval) self.analyze_tuple_or_list_lvalue(lval, explicit_type) elif isinstance(lval, StarExpr): if nested: diff --git a/test-data/unit/README.md b/test-data/unit/README.md index e1923b90ad52d..d8a42f4bc4446 100644 --- a/test-data/unit/README.md +++ b/test-data/unit/README.md @@ -7,7 +7,8 @@ Quick Start To add a simple unit test for a new feature you developed, open or create a `test-data/unit/check-*.test` file with a name that roughly relates to the -feature you added. +feature you added. If you added a new `check-*.test` file, add it to the list +of files in `mypy/test/testcheck.py`. Add the test in this format anywhere in the file: diff --git a/test-data/unit/check-tuples.test b/test-data/unit/check-tuples.test index ec3c2bc48c1b5..55bee11b699fb 100644 --- a/test-data/unit/check-tuples.test +++ b/test-data/unit/check-tuples.test @@ -1458,3 +1458,15 @@ x7, x8, y7, y8 = *points2, *points3 # E: Contiguous iterable with same type expe x9, y9, x10, y10, z5 = *points2, 1, *points2 # E: Contiguous iterable with same type expected [builtins fixtures/tuple.pyi] + +[case testAssignEmptyPy36] +# flags: --python-version 3.6 +() = [] + +[case testAssignEmptyPy27] +# flags: --python-version 2.7 +() = [] # E: can't assign to () + +[case testAssignEmptyBogus] +() = 1 # E: 'Literal[1]?' object is not iterable +[builtins fixtures/tuple.pyi] diff --git a/test-data/unit/semanal-errors.test b/test-data/unit/semanal-errors.test index e093f3fd1a0a8..7933341b9079e 100644 --- a/test-data/unit/semanal-errors.test +++ b/test-data/unit/semanal-errors.test @@ -377,11 +377,6 @@ main:1: error: can't assign to literal [out] main:1: error: can't assign to literal -[case testInvalidLvalues5] -() = 1 -[out] -main:1: error: can't assign to () - [case testInvalidLvalues6] x = y = z = 1 # ok x, (y, 1) = 1