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

E999 syntax error for match statement #680

Closed
thosil opened this issue Nov 11, 2022 · 8 comments · Fixed by #1228
Closed

E999 syntax error for match statement #680

thosil opened this issue Nov 11, 2022 · 8 comments · Fixed by #1228

Comments

@thosil
Copy link

thosil commented Nov 11, 2022

ruff throw a syntax error for code like this:

import sys

value: str = sys.argv[1]

match value:
    case "ruff":
        print("Rough?")
    case "awesome":
        print("Of course is it!")
    case _:
        print("what?")
$ ruff ruff_and_match.py
Found 1 error(s).
ruff_and_match.py:5:8: E999 SyntaxError: invalid syntax. Got unexpected token 'value'

versions

  • Python 3.10.6
  • ruff 0.0.108

config:

[tool.ruff]
line-length = 100
select=["E", "F", "W", "U", "N", "C", "B", "A", "T", "Q", "RUF", "M", "ANN"]
ignore=["F403", "F405", "B008", "A003"]

(and yes ruff is awesome ;-))

@squiddy
Copy link
Contributor

squiddy commented Nov 11, 2022

Yeah, ruff is using RustPython which doesn't support match yet.

Also see #282 and #54

There is a note in the README, but it's a bit hidden.

Ruff does not yet support a few Python 3.9 and 3.10 language features, including structural pattern matching and parenthesized context managers.

@thosil
Copy link
Author

thosil commented Nov 11, 2022

ok, sorry for the noise 😬

@thosil thosil closed this as completed Nov 11, 2022
@squiddy
Copy link
Contributor

squiddy commented Nov 11, 2022

No worries, just pointing it out. :) I think Charlie is working on alternatives to RustPython that could fix that.

@charliermarsh
Copy link
Member

Yeah, sadly those aren't supported yet. Another possibility is rewriting the RustPython parser to support that syntax! (It has to be rewritten anyway, CPython itself moved to a new parser to support those expressions which were "impossible" in the old parser.)

@charliermarsh
Copy link
Member

(For clarity: this is still open, but a dupe of #282.)

@charliermarsh
Copy link
Member

Fixed as of v0.0.250 which included match statement support.

@eddyg
Copy link

eddyg commented Feb 23, 2023

Holy cow! 🎉 That's fantastic news, Charlie! Can't wait to replace all my elif chains with match statements now. 😄

@charliermarsh
Copy link
Member

🎸 🎸 🎸

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

Successfully merging a pull request may close this issue.

4 participants