diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index d87605d..2cd57d2 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -448,9 +448,16 @@ class ErrorFinder(Normalizer): if error is None: if second.type in ('dictorsetmaker', 'string'): error = 'literal' - elif first == '(': + elif first in ('(', '['): if second.type == 'yield_expr': error = 'yield expression' + elif second.type == 'testlist_comp': + # This is not a comprehension, they were handled + # further above. + for child in second.children[::2]: + self._check_assignment(child, is_deletion) + else: # Everything handled, must be useless brackets. + self._check_assignment(second, is_deletion) elif type_ == 'keyword': error = 'keyword' elif type_ == 'operator': @@ -464,6 +471,9 @@ class ErrorFinder(Normalizer): # This one seems to be a slightly different warning in Python. message = 'assignment to yield expression not possible' self._add_syntax_error(message, node) + elif type_ == 'test': + error = 'conditional expression' + print(node) if error is not None: message = "can't %s %s" % ("delete" if is_deletion else "assign to", error) diff --git a/test/test_python_errors.py b/test/test_python_errors.py index 81dee34..dbd8b92 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -116,10 +116,10 @@ def test_indentation_errors(code, positions): 'b"" = 1', '"" "" = 1', 'def foo(): (yield 1) = 3', - 'def foo(): x = yield 1 = 3' - '', - #'(True,) = x', - #'([False], a) = x', + 'def foo(): x = yield 1 = 3', + '(a if a else a) = a', + '(True,) = x', + '([False], a) = x', # SyntaxErrors from Python/symtable.c 'def f(x, x): pass',