Summary
When running ruff check for the first time on a Python file (version 3.13.1) containing match statements (ie either when ruff has just been installed, or the file has just been created), the error
SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
is returned. This error is hard to debug as it will not appear for subsequent runs of ruff check in the same repo (all checks pass) -- I suspect this is why I've been unable to replicate in the playground
Replicated in Python 3.12 and Python 3.13 on Mac running Sequoia 15.3.1, and for the same Python versions on a Windows machine running WSL. MWE here: ruff-demo.zip
As a short-term fix you can either revert to ruff<=0.9.7 or include the line target-version = "py313" in your ruff config (I assume it would work for any version >3.9)
Version
ruff 0.9.8 (568cf88 2025-02-27)