From e776e2a13d6b713b4799e60312b8756c00fa1f41 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 26 Jul 2017 23:08:36 +0200 Subject: [PATCH] Add issues if users want to assign to operators. --- parso/python/normalizer.py | 11 +++++++++++ test/test_python_errors.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 2cd57d2..8af4dfb 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -473,6 +473,17 @@ class ErrorFinder(Normalizer): self._add_syntax_error(message, node) elif type_ == 'test': error = 'conditional expression' + elif type_ == 'atom_expr': + if node.children[0] == 'await': + error = 'await expression' + elif type_ in ('testlist_star_expr', 'exprlist'): + for child in node.children[::2]: + self._check_assignment(child, is_deletion) + elif ('expr' in type_ and type_ != 'star_expr' # is a substring + or '_test' in type_ + or type_ in ('term', 'factor')): + error = 'operator' + print(node) if error is not None: diff --git a/test/test_python_errors.py b/test/test_python_errors.py index dbd8b92..dd44307 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -115,11 +115,17 @@ def test_indentation_errors(code, positions): 'b"" = 1', 'b"" = 1', '"" "" = 1', + '1 | 1 = 3', + '~ 1 = 3', + 'not 1 = 3', + '1 and 1 = 3', 'def foo(): (yield 1) = 3', 'def foo(): x = yield 1 = 3', + 'async def foo(): await x = 3', '(a if a else a) = a', '(True,) = x', '([False], a) = x', + 'a, 1 = x', # SyntaxErrors from Python/symtable.c 'def f(x, x): pass',