Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- #786 Upgrade Actions used in Github Workflows (@lieryan)
- #785 Refactoring movetest.py (@lieryan)
- #788 Introduce the `preferred_import_style` configuration (@nicoolas25, @lieryan)
- #819 supports MatchOr, MatchSequence, MatchStar (@jheld)

# Release 1.13.0

Expand Down
14 changes: 14 additions & 0 deletions rope/refactor/patchedast.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,13 @@ def _Match(self, node):
children.extend(node.cases)
self._handle(node, children)

def _MatchOr(self, node):
children = [*self._child_nodes(node.patterns, "|")]
self._handle(node, children)

def _MatchSingleton(self, node):
self._handle(node, [str(node.value)])

def _match_case(self, node):
children = ["case", node.pattern]
if node.guard:
Expand All @@ -793,6 +800,13 @@ def _match_case(self, node):
children.extend(node.body)
self._handle(node, children)

def _MatchSequence(self, node):
children = ["[", *self._child_nodes(node.patterns, ","), "]"]
self._handle(node, children)

def _MatchStar(self, node):
self._handle(node, ["*_"])

def _MatchAs(self, node):
if node.pattern:
children = [node.pattern, "as", node.name]
Expand Down
Loading