python-3.xpython-3.10linterruff

ruff : E999 SyntaxError on match/case syntax


I got a strange issue with ruff (0.0.209) and python 3.10.9 interpreter when I use match/case syntax. For instance, this simple code :

from http import HTTPStatus

http_status = HTTPStatus.OK

match http_status:
    case HTTPStatus.OK:
        print("OK!")

    case HTTPStatus.BAD_REQUEST:
        print("Bad, bad Zoot!")

    case _:
        print("Just a flesh wound.")

Raise a 5:8: E999 SyntaxError: invalid syntax. Got unexpected token 'http_status'

At the same time, ruff argue that it now support python3.11. Who is lying ? :)

I tried to update ruff with last version


Solution

  • It's not supported as of 2023-01-06 unfortunately. This is the tracking issue.

    Update (2023-03-11): Get ruff 0.0.250 or above.