Skip to content

patchedast is currently not handling some match-case statement syntaxes #623

Closed

Description

@lieryan

Is your feature request related to a problem? Please describe.

#456 adds pattern matching to rope, but it seems like support is incomplete as patchedast currently doesn't handle these nodes:

'MatchOr',
'MatchSequence',
'MatchSingleton',
'MatchStar',

This will likely cause extract refactoring to have issues when these syntaxes are being used.

Describe the solution you'd like

Implement these nodes.

Docs on how to implement this

Activity

  1. mcepl commented on Nov 2, 2026

    @mcepl
    Contributor

    All four nodes listed here are implemented. #819 added MatchOr, MatchSequence, MatchSingleton and MatchStar, #863 fixed the parenthesis handling for MatchSequence, and both are in 1.15.0. On master (46ebf37) a pattern of each kind now round-trips through write_ast().

    Two MatchSequence cases still fail on master:

    • case (1), (2): raises MismatchedTokenError: Token <)> at (2, 17) cannot be matched.
    • case (("a" | None), None): warns Unexpected character in MatchSequence's opening_paren <((>, and write_ast() no longer reproduces the source.

    Item 3 of the open PR #882 addresses both. Would you close this once #882 is merged, or close it now and leave the corner cases to #882?

  2. lieryan commented on Nov 2, 2026

    @lieryan
    MemberAuthor

    Let's close this. #882 can be its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions