From 00bc1a5b945e6cce65caaef5ea948dff130e8206 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 25 Jul 2017 00:58:08 +0200 Subject: [PATCH] Add issue 'keyword can't be an expression' --- parso/python/normalizer.py | 4 ++++ test/test_python_errors.py | 1 + 2 files changed, 5 insertions(+) diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 7f10838..5b132af 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -231,6 +231,10 @@ class ErrorFinder(Normalizer): self._add_syntax_error(message, lhs.parent) else: self._add_syntax_error(message % type_, lhs.parent) + elif node.type == 'argument': + if node.children[1] == '=' and node.children[0].type != 'name': + message = "keyword can't be an expression" + self._add_syntax_error(message, node.children[0]) yield diff --git a/test/test_python_errors.py b/test/test_python_errors.py index d1521b6..82f5aa5 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -90,6 +90,7 @@ def test_indentation_errors(code, positions): '(a, b): int', '*star,: int', 'a, b: int = 3', + 'foo(+a=3)', # IndentationError ' foo',