Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PEP634: match and case/structural pattern matching #1140

Closed
ashb opened this issue Dec 8, 2022 · 3 comments
Closed

Add support for PEP634: match and case/structural pattern matching #1140

ashb opened this issue Dec 8, 2022 · 3 comments

Comments

@ashb
Copy link
Contributor

ashb commented Dec 8, 2022

I'm trying out ruff on a greenfield project (loving it so far! Thank you for it!) where I get to use all the latest python goodies, and I've discovered that it doesn't seem like ruff (v0.0.169) likes match/case:

Simple example:

ruff - <<EOF
name = "abc"
match name:
    case "def":
        print("def")
    case _:
        print("default")

EOF
Found 1 error(s).
-:2:8: E999 SyntaxError: invalid syntax. Got unexpected token 'name'

(Replace ruff with python and it'll run fine, of course.)

This syntax was added via https://peps.python.org/pep-0634/ in Python 3.10

I'll won't be able to get around to attempting a PR for this before the New Year, if someone beats me to it I owe you a drink of your choice!

@g-as
Copy link
Contributor

g-as commented Dec 8, 2022

Duplicate #680

@ashb
Copy link
Contributor Author

ashb commented Dec 8, 2022

Close as duplicate of #282 - sorry I clearly massively failed in searching (I think I was looking for case match and not "pattern matching". I wasn't aware that is what it was called in python until I went to find the PEP for it)

@ashb ashb closed this as completed Dec 8, 2022
@g-as
Copy link
Contributor

g-as commented Dec 8, 2022

No worries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants