Skip to content

Commit

Permalink
Merge pull request #117 from isidentical/repeated-kwarg-39
Browse files Browse the repository at this point in the history
Show which keyword argument is repeated on 3.9+
  • Loading branch information
davidhalter committed May 23, 2020
2 parents a06521d + 27a7c16 commit 6ecd975
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion parso/python/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,10 @@ def is_issue(self, node):
if first.type == 'name':
if first.value in arg_set:
# f(x=1, x=2)
self.add_issue(first, message="keyword argument repeated")
message = "keyword argument repeated"
if self._normalizer.version >= (3, 9):
message += ": {}".format(first.value)
self.add_issue(first, message=message)
else:
arg_set.add(first.value)
else:
Expand Down
16 changes: 13 additions & 3 deletions test/test_python_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ def test_continue_in_finally():
]
)
def test_forbidden_name(template, target):
assert _get_error_list(template.format(target=target), version="3")[0].message


assert _get_error_list(template.format(target=target), version="3")


def test_repeated_kwarg():
# python 3.9+ shows which argument is repeated
assert (
_get_error_list("f(q=1, q=2)", version="3.8")[0].message
== "SyntaxError: keyword argument repeated"
)
assert (
_get_error_list("f(q=1, q=2)", version="3.9")[0].message
== "SyntaxError: keyword argument repeated: q"
)

0 comments on commit 6ecd975

Please sign in to comment.