Skip to content

Type Parameter Modernization: Port TypeVarCheck to libcst - #281

Open
FrancescoPezzella wants to merge 108 commits into
typing-recipes-2from
typing-recipes-2-cst-structure
Open

FrancescoPezzella wants to merge 108 commits into
typing-recipes-2from
typing-recipes-2-cst-structure

Conversation

@FrancescoPezzella

Copy link
Copy Markdown
Collaborator

No description provided.

@FrancescoPezzella
FrancescoPezzella added this pull request to stack #277 October 13, 2026 08:19
@FrancescoPezzella FrancescoPezzella changed the title Typing recipes 2 cst structure Type Parameter - CST Structure Overhaul Oct 13, 2026
@FrancescoPezzella
FrancescoPezzella force-pushed the typing-recipes-2-cst-structure branch from c99aa4d to 8ab7782 Compare October 13, 2026 08:22
@FrancescoPezzella FrancescoPezzella changed the title Type Parameter - CST Structure Overhaul Type Parameter - Port TypeVarCheck to libcst Oct 13, 2026
@FrancescoPezzella FrancescoPezzella self-assigned this Oct 13, 2026
@FrancescoPezzella FrancescoPezzella added documentation Improvements or additions to documentation enhancement New feature or request python language Issues related to analysis and transformation of the Python language labels Oct 13, 2026
@FrancescoPezzella
FrancescoPezzella marked this pull request as ready for review October 13, 2026 12:19
…rameter modernization feature page, define type hint, type parameter and type variable, and fix the test file name in the rewrite-semantics module doc.
… over NodeProtocol

ASTNode now satisfies NodeProtocol, so adapters that don't subclass ASTNode (RST, CST, LST) type-check, and clang references keep their concrete node type (#269).
Overall around 10 % (600) PyRight issues solved with this PR
@FrancescoPezzella
FrancescoPezzella removed this pull request from stack #277 October 16, 2026 11:58
…pansThe three CST xfails in test_offset_encoding now pass; spans match the RST backend (decorators included, trailing newline excluded).
references/referenced_by link each use to its definition (string annotations included), so MatchFinder's reference matching now works on the CST backend.
PythonRefactoring is generic over the node class (RST by default), and body returns the module's top-level statements on both backends.
libcst only links a use to definitions above it; annotations and type hints are evaluated lazily, so they now count too.
…rameters. Type Vars can now be safely converted, even if the imports cannot be deleted (before it was all or nothing), now a partial fix is applied.
…CONFLICT`. Detect name conflicts in the file when localizing a Type Var with for example a bound=Box, where Box is already defined in the file.
…n Covariant/Contravariant/Bound is added to ParamSpec/TypeVarTuple, the change becomes unsafe since a modern syntax for it does not exist.
Fixes the conflicting-rewrite ValueError on `from x import T, U`; each needed import is added once.
…file

The origin's `from ._compat import TypeVar` is now rewritten relative to the importing file instead of losing its dots.
…tected after a numerous amount of checks).
…ze_import, moving its relative-import and alias cases to the localization tests. Documented a bug with comments being lost.
Add a placeholder copyright header to the new files and give the PR's TODOs an author and issue link (#189, #269, #279, #280).
@FrancescoPezzella FrancescoPezzella removed the documentation Improvements or additions to documentation label Oct 16, 2026
Analysis and rewriting now use libcst only, so uses in string annotations and names shadowed by a class's own type parameters are handled, multi-line strings and import comments are kept, and unparse_utils is removed.
…er bugs in TODOs

Link the rewriter, TextUtils and UnitToPytest spots to #283, and the is_ancestor_of crash to #284.
… __is_ancestor_in_nodes can't just drop its `and False` (#286).

Move import_from_module and imported_name to import_resolution, so the import-from logic exists once.
@FrancescoPezzella
FrancescoPezzella force-pushed the typing-recipes-2-cst-structure branch from a581268 to e12c0e7 Compare October 16, 2026 15:03
@FrancescoPezzella
FrancescoPezzella added this pull request to stack #295 October 16, 2026 15:04
@FrancescoPezzella FrancescoPezzella changed the title Type Parameter - Port TypeVarCheck to libcst Type Parameter Modernization: Port TypeVarCheck to libcst Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python language Issues related to analysis and transformation of the Python language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant