Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# **Upcoming release**

- ...
- #895 patchedast Starred and keyword now consumes their syntactically expected and ** (lieryan)

# Release 1.15.0

Expand Down
4 changes: 2 additions & 2 deletions rope/refactor/patchedast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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, ":"]
Expand Down
14 changes: 7 additions & 7 deletions ropetest/refactor/patchedasttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -1397,15 +1397,15 @@ 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):
source = "foo(a=1, *args)\n"
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")
Expand Down
Loading