Skip to content

Support Python 3.10 pattern matching syntax #2242

@tirkarthi

Description

@tirkarthi

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

Python 3.10 has added support for pattern matching. It will be good to support it. https://www.python.org/dev/peps/pep-0622/

Describe the solution you'd like .

Describe alternatives you've considered

Reproducer

from dataclasses import dataclass

@dataclass
class Person:
    name: str

person = Person("Kate")

match person:
    case Person(name):
        print(f"Found {name}")
    case _:
        print("Not found")
 black /tmp/dataclass_match.py
error: cannot format /tmp/dataclass_match.py: Cannot parse: 10:6: match person:
Oh no! 💥 💔 💥
1 file failed to reformat.

Additional context Add any other context or screenshots about the feature request
here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: parserHow we parse code. Or fail to parse it.S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedT: enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions