Skip to content

Commit

Permalink
Correct a trailing comma bug in parameter list
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Oct 18, 2024
1 parent 07da017 commit 0ce2316
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rewrite/rewrite/python/_parser_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def visit_arguments(self, node, with_close_paren: bool = True) -> List[JRightPad
for i, kwonlyarg in enumerate(node.kwonlyargs):
args.append(self.__pad_list_element(
self.map_arg(kwonlyarg, node.kw_defaults[i], kwarg=False),
i == len(node.kwonlyargs) - 1,
not node.kwarg and i == len(node.kwonlyargs) - 1,
end_delim=')' if with_close_paren else None
))

Expand Down
12 changes: 12 additions & 0 deletions rewrite/tests/python/all/method_declaration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ def foo(foo, *, bar) :
)


def test_all():
# language=python
rewrite_run(
python(
"""\
def retry_until_timeout(cb_fn, *args, timeout=4, **kwargs):
pass
"""
)
)


def test_trailing_comma_on_kwonly_arg():
# language=python
rewrite_run(
Expand Down

0 comments on commit 0ce2316

Please sign in to comment.