Skip to content

Commit e4e9908

Browse files
authored
Merge pull request #895 from python-rope/lieryan-consume-starred
patchedast Starred and keyword now consumes their syntactically expected * and **
2 parents 2bd17a8 + 1155c2b commit e4e9908

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# **Upcoming release**
22

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

55
# Release 1.15.0
66

‎rope/refactor/patchedast.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def _Import(self, node):
589589

590590
def _keyword(self, node):
591591
if node.arg is None:
592-
children = [node.value]
592+
children = ["**", node.value]
593593
else:
594594
children = [node.arg, "=", node.value]
595595
self._handle(node, children)
@@ -779,7 +779,7 @@ def _AsyncWith(self, node):
779779
self._handle_with_node(node, is_async=True)
780780

781781
def _Starred(self, node):
782-
self._handle(node, [node.value])
782+
self._handle(node, ["*", node.value])
783783

784784
def _Match(self, node):
785785
children = ["match", node.subject, ":"]

‎ropetest/refactor/patchedasttest.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def test_call_func_and_star_argspython35(self):
547547
ast_frag = patchedast.get_patched_ast(source, True)
548548
checker = _ResultChecker(self, ast_frag)
549549
checker.check_children(
550-
"Call", ["Name", "", "(", "", "Num", "", ",", " *", "Starred", "", ")"]
550+
"Call", ["Name", "", "(", "", "Num", "", ",", " ", "Starred", "", ")"]
551551
)
552552

553553
@testutils.only_for_versions_lower("3.5")
@@ -561,7 +561,7 @@ def test_call_func_and_only_dstar_args_python35(self):
561561
source = "f(**kwds)\n"
562562
ast_frag = patchedast.get_patched_ast(source, True)
563563
checker = _ResultChecker(self, ast_frag)
564-
checker.check_children("Call", ["Name", "", "(", "**", "keyword", "", ")"])
564+
checker.check_children("Call", ["Name", "", "(", "", "keyword", "", ")"])
565565

566566
@testutils.only_for_versions_lower("3.5")
567567
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):
579579
checker = _ResultChecker(self, ast_frag)
580580
checker.check_children(
581581
"Call",
582-
["Name", "", "(", "*", "Starred", "", ",", " **", "keyword", "", ")"],
582+
["Name", "", "(", "", "Starred", "", ",", " ", "keyword", "", ")"],
583583
)
584584

585585
def test_class_node(self):
@@ -1379,7 +1379,7 @@ def test_starargs_before_keywords(self):
13791379
ast_frag = patchedast.get_patched_ast(source, True)
13801380
checker = _ResultChecker(self, ast_frag)
13811381
checker.check_children(
1382-
"Call", ["Name", "", "(", "*", "Starred", "", ",", " ", "keyword", "", ")"]
1382+
"Call", ["Name", "", "(", "", "Starred", "", ",", " ", "keyword", "", ")"]
13831383
)
13841384

13851385
def test_starargs_in_keywords(self):
@@ -1388,7 +1388,7 @@ def test_starargs_in_keywords(self):
13881388
checker = _ResultChecker(self, ast_frag)
13891389
checker.check_children(
13901390
"Call",
1391-
["Name", "", "(", "", "keyword", "", ",", " *", "Starred", "", ",", " ", "keyword", "", ")"],
1391+
["Name", "", "(", "", "keyword", "", ",", " ", "Starred", "", ",", " ", "keyword", "", ")"],
13921392
)
13931393

13941394
def test_starargs_in_positional(self):
@@ -1397,15 +1397,15 @@ def test_starargs_in_positional(self):
13971397
checker = _ResultChecker(self, ast_frag)
13981398
checker.check_children(
13991399
"Call",
1400-
["Name", "", "(", "", "Name", "", ",", " *", "Starred", "", ",", " ", "Name", "", ")"],
1400+
["Name", "", "(", "", "Name", "", ",", " ", "Starred", "", ",", " ", "Name", "", ")"],
14011401
)
14021402

14031403
def test_starargs_after_keywords(self):
14041404
source = "foo(a=1, *args)\n"
14051405
ast_frag = patchedast.get_patched_ast(source, True)
14061406
checker = _ResultChecker(self, ast_frag)
14071407
checker.check_children(
1408-
"Call", ["Name", "", "(", "", "keyword", "", ",", " *", "Starred", "", ")"]
1408+
"Call", ["Name", "", "(", "", "keyword", "", ",", " ", "Starred", "", ")"]
14091409
)
14101410

14111411
@testutils.only_for_versions_higher("3.5")

0 commit comments

Comments
 (0)