mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Show which keyword argument is repeated on 3.9+
This commit is contained in:
@@ -817,7 +817,10 @@ class _ArglistRule(SyntaxRule):
|
||||
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:
|
||||
|
||||
@@ -359,6 +359,10 @@ 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 "q" not in _get_error_list("f(q=1, q=2)", version="3.8")[0].message
|
||||
assert "q" in _get_error_list("f(q=1, q=2)", version="3.9")[0].message
|
||||
|
||||
Reference in New Issue
Block a user