Skip to content

Commit d60d56a

Browse files
committed
supports Match: Or, Sequence, Star, Singleton
1 parent 55169bb commit d60d56a

File tree

3 files changed

+801
-237
lines changed

3 files changed

+801
-237
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- #786 Upgrade Actions used in Github Workflows (@lieryan)
55
- #785 Refactoring movetest.py (@lieryan)
66
- #788 Introduce the `preferred_import_style` configuration (@nicoolas25, @lieryan)
7+
- #819 supports MatchOr, MatchSequence, MatchStar (@jheld)
78

89
# Release 1.13.0
910

rope/refactor/patchedast.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,13 @@ def _Match(self, node):
785785
children.extend(node.cases)
786786
self._handle(node, children)
787787

788+
def _MatchOr(self, node):
789+
children = [*self._child_nodes(node.patterns, "|")]
790+
self._handle(node, children)
791+
792+
def _MatchSingleton(self, node):
793+
self._handle(node, [str(node.value)])
794+
788795
def _match_case(self, node):
789796
children = ["case", node.pattern]
790797
if node.guard:
@@ -793,6 +800,13 @@ def _match_case(self, node):
793800
children.extend(node.body)
794801
self._handle(node, children)
795802

803+
def _MatchSequence(self, node):
804+
children = ["[", *self._child_nodes(node.patterns, ","), "]"]
805+
self._handle(node, children)
806+
807+
def _MatchStar(self, node):
808+
self._handle(node, ["*_"])
809+
796810
def _MatchAs(self, node):
797811
if node.pattern:
798812
children = [node.pattern, "as", node.name]

0 commit comments

Comments
 (0)