Skip to content

Add Python 3.14 support (PEP 758 except syntax) & bump to 1.4.0#327

Merged
hakancelikdev merged 2 commits into
mainfrom
fix/pep-758-except-syntax
Jun 2, 2026
Merged

Add Python 3.14 support (PEP 758 except syntax) & bump to 1.4.0#327
hakancelikdev merged 2 commits into
mainfrom
fix/pep-758-except-syntax

Conversation

@hakancelikdev

Copy link
Copy Markdown
Owner

Closes #326

Summary

  • Adds Python 3.14 to requires-python, classifiers, tox envlist, and CI matrix
  • Raises libcst upper pin from <=1.8.2 to <=1.8.6 so the refactor pipeline can parse the new PEP 758 except clause syntax (except ValueError, TypeError: without parens). libcst < 1.8.3 raises ParserSyntaxError on the new form
  • Adds PY314_PLUS constant and wires it into the skipif harness in tests/cases/test_cases.py
  • New test triplet tests/cases/{source,analyzer,refactor}/error/try_except_no_parens.py covering two- and three-exception variants
  • Bumps version to 1.4.0 and updates CHANGELOG / action.yml / pre-commit config / docs

The Python ast representation is identical for the parenthesized and parens-less forms, so no analyzer changes were needed. The whole fix sits in dependency bounds + a regression test.

Test plan

  • pytest tests --disable-warnings passes on Python 3.12 (libcst 1.8.6) — 184 passed, 1 skipped (Windows-only)
  • pytest tests --disable-warnings passes on Python 3.14.4 (libcst 1.8.6) — analyzer assertions actually run on the new test
  • pre-commit run --all-files passes on the pre-bump commit (the bump commit itself self-references the new tag, hence committed with --no-verify as in previous version bumps)
  • End-to-end CLI check on 3.14: python -m unimport sample.py --diff correctly removes unused imports from a file containing except ValueError, TypeError:

🤖 Generated with Claude Code

hakancelikdev and others added 2 commits June 2, 2026 15:22
Python 3.14 makes parentheses optional around tuples of exception types
in `except` clauses (PEP 758), e.g. `except ValueError, TypeError:`.

The fix has two parts:

1. Allow Python 3.14 in `requires-python` and add the matching classifier,
   tox env, and CI matrix entry.
2. Raise the libcst upper pin to `1.8.6`. libcst < 1.8.3 cannot parse the
   new syntax; bumping the pin lets refactor_string round-trip files that
   use it. The Python ast representation is identical for parenthesized
   and non-parenthesized forms, so no analyzer changes are needed.

Adds a test triplet under `tests/cases/{source,analyzer,refactor}/error/`
covering two- and three-exception variants of the new syntax. Adds the
`PY314_PLUS` constant for the skipif harness.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hakancelikdev hakancelikdev merged commit bd2e7d9 into main Jun 2, 2026
37 of 41 checks passed
@hakancelikdev hakancelikdev deleted the fix/pep-758-except-syntax branch June 2, 2026 15:28
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.

Python 3.14 exception format.

1 participant