From 1155c2b76e4e8f9122820ac022815be586be09b3 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Thu, 8 Oct 2026 00:55:42 +1100 Subject: [PATCH] patchedast Starred and keyword now consumes their syntactically expected * and ** --- CHANGELOG.md | 2 +- rope/refactor/patchedast.py | 4 ++-- ropetest/refactor/patchedasttest.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff6f27ed8..743e2690b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # **Upcoming release** -- ... +- #895 patchedast Starred and keyword now consumes their syntactically expected and ** (lieryan) # Release 1.15.0 diff --git a/rope/refactor/patchedast.py b/rope/refactor/patchedast.py index 2ea194d16..a30b04404 100644 --- a/rope/refactor/patchedast.py +++ b/rope/refactor/patchedast.py @@ -589,7 +589,7 @@ def _Import(self, node): def _keyword(self, node): if node.arg is None: - children = [node.value] + children = ["**", node.value] else: children = [node.arg, "=", node.value] self._handle(node, children) @@ -779,7 +779,7 @@ def _AsyncWith(self, node): self._handle_with_node(node, is_async=True) def _Starred(self, node): - self._handle(node, [node.value]) + self._handle(node, ["*", node.value]) def _Match(self, node): children = ["match", node.subject, ":"] diff --git a/ropetest/refactor/patchedasttest.py b/ropetest/refactor/patchedasttest.py index 6998b24f7..353933fbe 100644 --- a/ropetest/refactor/patchedasttest.py +++ b/ropetest/refactor/patchedasttest.py @@ -547,7 +547,7 @@ def test_call_func_and_star_argspython35(self): ast_frag = patchedast.get_patched_ast(source, True) checker = _ResultChecker(self, ast_frag) checker.check_children( - "Call", ["Name", "", "(", "", "Num", "", ",", " *", "Starred", "", ")"] + "Call", ["Name", "", "(", "", "Num", "", ",", " ", "Starred", "", ")"] ) @testutils.only_for_versions_lower("3.5") @@ -561,7 +561,7 @@ def test_call_func_and_only_dstar_args_python35(self): source = "f(**kwds)\n" ast_frag = patchedast.get_patched_ast(source, True) checker = _ResultChecker(self, ast_frag) - checker.check_children("Call", ["Name", "", "(", "**", "keyword", "", ")"]) + checker.check_children("Call", ["Name", "", "(", "", "keyword", "", ")"]) @testutils.only_for_versions_lower("3.5") def test_call_func_and_both_varargs_and_kwargs(self): @@ -579,7 +579,7 @@ def test_call_func_and_both_varargs_and_kwargs_python35(self): checker = _ResultChecker(self, ast_frag) checker.check_children( "Call", - ["Name", "", "(", "*", "Starred", "", ",", " **", "keyword", "", ")"], + ["Name", "", "(", "", "Starred", "", ",", " ", "keyword", "", ")"], ) def test_class_node(self): @@ -1379,7 +1379,7 @@ def test_starargs_before_keywords(self): ast_frag = patchedast.get_patched_ast(source, True) checker = _ResultChecker(self, ast_frag) checker.check_children( - "Call", ["Name", "", "(", "*", "Starred", "", ",", " ", "keyword", "", ")"] + "Call", ["Name", "", "(", "", "Starred", "", ",", " ", "keyword", "", ")"] ) def test_starargs_in_keywords(self): @@ -1388,7 +1388,7 @@ def test_starargs_in_keywords(self): checker = _ResultChecker(self, ast_frag) checker.check_children( "Call", - ["Name", "", "(", "", "keyword", "", ",", " *", "Starred", "", ",", " ", "keyword", "", ")"], + ["Name", "", "(", "", "keyword", "", ",", " ", "Starred", "", ",", " ", "keyword", "", ")"], ) def test_starargs_in_positional(self): @@ -1397,7 +1397,7 @@ def test_starargs_in_positional(self): checker = _ResultChecker(self, ast_frag) checker.check_children( "Call", - ["Name", "", "(", "", "Name", "", ",", " *", "Starred", "", ",", " ", "Name", "", ")"], + ["Name", "", "(", "", "Name", "", ",", " ", "Starred", "", ",", " ", "Name", "", ")"], ) def test_starargs_after_keywords(self): @@ -1405,7 +1405,7 @@ def test_starargs_after_keywords(self): ast_frag = patchedast.get_patched_ast(source, True) checker = _ResultChecker(self, ast_frag) checker.check_children( - "Call", ["Name", "", "(", "", "keyword", "", ",", " *", "Starred", "", ")"] + "Call", ["Name", "", "(", "", "keyword", "", ",", " ", "Starred", "", ")"] ) @testutils.only_for_versions_higher("3.5")