Skip to content

ci: pin pre-commit python to 3.14 for PEP 758 bare-except tuples - #804

Merged
c-vigo merged 1 commit into
devfrom
chore/803-parenthesize-except-tuples
Jul 3, 2026
Merged

c-vigo merged 1 commit into
devfrom
chore/803-parenthesize-except-tuples

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the recurring SyntaxError: multiple exception types must be parenthesized false-positive, and settles the underlying style question: keep the PEP 758 unparenthesized except X, Y: form (the forward Python standard) and fix the tooling instead of the code.

Why not just parenthesize?

except X, Y: (no parens) is PEP 758, valid on Python 3.14+ and permanently going forward (verified: ruff format strips added parens at both target py314 and py315). The repo targets py314, so ruff emits this form — parenthesizing to except (X, Y): fights the formatter and would be reverted on every ruff format. requires-python >=3.14 means consumers are 3.14+ anyway. So the syntax is correct and future-proof; only pre-3.14 parsers choke on it.

Root cause + fix

The flake-provided pre-commit is itself a Python-3.13 app, so it builds its debug-statements hook env with 3.13 → rejects the syntax on a bare local pre-commit run. CI is green because it runs pre-commit under the project's 3.14.

Fix — pin the hook interpreter:

default_language_version:
  python: python3.14

Verified: after the pin, a bare flake pre-commit run --all-files is fully green (the debug-statements hook now builds its env with 3.14). No code changed; the two files using the syntax (tests/conftest.py, packages/vig-utils/tests/test_claude_ssot.py) stay as-is.

Notes

  • The mirrored downstream assets/workspace/.pre-commit-config.yaml gets the same pin via sync-manifest.
  • Bump the pin alongside requires-python on future Python upgrades.
  • Follow-up: record the "embrace PEP 758, don't parenthesize" convention in the org standards SSoT (vig-os/meta/docs).

Refs: #803

The flake-provided `pre-commit` is a Python-3.13 application, so it builds
its python-language hook envs (e.g. debug-statements) with 3.13, which
rejects the PEP 758 unparenthesized `except X, Y:` syntax the codebase
uses (valid on Python 3.14+, and what `ruff format` emits at target py314).
That produced a false `SyntaxError: multiple exception types must be
parenthesized` on a bare local `pre-commit run`, even though the code is
correct and CI (running pre-commit under the project's 3.14) is green.

Pin `default_language_version: python: python3.14` so every python hook
uses the project interpreter regardless of how pre-commit is invoked.
Keeps the forward-standard syntax instead of parenthesizing (which ruff
would revert). Bump alongside requires-python.

Refs: #803
@c-vigo
c-vigo merged commit 5bfaa28 into dev Jul 3, 2026
13 checks passed
@c-vigo
c-vigo deleted the chore/803-parenthesize-except-tuples branch July 3, 2026 07:44
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 this pull request may close these issues.

1 participant