You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ruff erroneously flagging modern syntax as syntax errors due to targeting Python 3.12 #144639
The reported syntax error appears to be a false positive.
The code uses except (FileNotFoundError, NotImplementedError):, which is valid Python 3.12 syntax.
This looks like a Ruff parser issue or an unintended lint of CPython Lib/test/support files.
Excluding Lib/test/** from E999 or upgrading Ruff should resolve this.
Run Ruff (lint) on Lib/test/.............................................Failed
- hook id: ruff-check
- exit code: 1
Error: Lib/test/support/import_helper.py:74:12: invalid-syntax: Multiple exception types must be parenthesized on Python 3.12 (syntax was added in Python 3.14)
@AlexWaygood Remind me of the reason for target-version = "py312"? Is it to ease backporting? In which case we could at least bump to py313, but that won't help here.
@AlexWaygood Remind me of the reason for target-version = "py312"? Is it to ease backporting? In which case we could at least bump to py313, but that won't help here.
I think the important thing is that this value needs to be set to the same as PYTHON_FOR_REGEN (which it is), so that our scripts in the Tools/ directory don't start accidentally using newer syntax than they're meant to:
. I haven't dug through the blame to see if I can figure out why it was originally set to py312, but off the top of my head, I think bumping the target version in Lib/test/.ruff.toml to py314 should be fine at this point! It might be that the reason it needs to be explicitly specified there is because we need to override the target version in the global config.
I haven't dug through the blame to see if I can figure out why it was originally set to py312
It was done in #137591 because a Ruff upgrade started giving "invalid-syntax: Cannot use type alias statement on Python 3.10 (syntax was added in Python 3.12)".
but off the top of my head, I think bumping the target version in Lib/test/.ruff.toml to py314 should be fine at this point!
Activity
BasavarajBankolli commentedon Feb 10, 2026
The reported syntax error appears to be a false positive.
The code uses except (FileNotFoundError, NotImplementedError):, which is valid Python 3.12 syntax.
This looks like a Ruff parser issue or an unintended lint of CPython Lib/test/support files.
Excluding Lib/test/** from E999 or upgrading Ruff should resolve this.
hugovk commentedon Feb 10, 2026
Because GH logs eventually expire, the error is:
Caused by:
We're already on the latest Ruff. Excluding E999 won't help, it's failing to parse the 3.14 syntax because it expects 3.12.
Here's one fix:
@AlexWaygood Remind me of the reason for
target-version = "py312"? Is it to ease backporting? In which case we could at least bump topy313, but that won't help here.AlexWaygood commentedon Feb 10, 2026
I think the important thing is that this value needs to be set to the same as
PYTHON_FOR_REGEN(which it is), so that our scripts in the Tools/ directory don't start accidentally using newer syntax than they're meant to:cpython/.ruff.toml
Line 4 in d2d2459
py312, but off the top of my head, I think bumping the target version inLib/test/.ruff.tomltopy314should be fine at this point! It might be that the reason it needs to be explicitly specified there is because we need to override the target version in the global config.hugovk commentedon Feb 10, 2026
It was done in #137591 because a Ruff upgrade started giving "invalid-syntax: Cannot use type alias statement on Python 3.10 (syntax was added in Python 3.12)".
Please see #144656.
gh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (#144656)
[3.14] pythongh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (…
[3.14] gh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (GH-1…
pythongh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (pytho…
pythongh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (pytho…
pythongh-144639: Ruff: target Python 3.14 syntax in `Lib/test` (pytho…