Add Python 3.14 support (PEP 758 except syntax) & bump to 1.4.0#327
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #326
Summary
requires-python, classifiers,toxenvlist, and CI matrix<=1.8.2to<=1.8.6so the refactor pipeline can parse the new PEP 758exceptclause syntax (except ValueError, TypeError:without parens). libcst < 1.8.3 raisesParserSyntaxErroron the new formPY314_PLUSconstant and wires it into the skipif harness intests/cases/test_cases.pytests/cases/{source,analyzer,refactor}/error/try_except_no_parens.pycovering two- and three-exception variantsThe Python
astrepresentation 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-warningspasses on Python 3.12 (libcst 1.8.6) — 184 passed, 1 skipped (Windows-only)pytest tests --disable-warningspasses on Python 3.14.4 (libcst 1.8.6) — analyzer assertions actually run on the new testpre-commit run --all-filespasses on the pre-bump commit (the bump commit itself self-references the new tag, hence committed with--no-verifyas in previous version bumps)python -m unimport sample.py --diffcorrectly removes unused imports from a file containingexcept ValueError, TypeError:🤖 Generated with Claude Code