Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
97dbbc5
TypeVar: First initial version with testing
FrancescoPezzella Aug 26, 2026
06e1625
TypeVar: Expanded upon the TypeVars - TypeVar/ParamSpec/TypeVarTuple.…
FrancescoPezzella Aug 26, 2026
d7dd993
TypeVar: Added type checking and fixed as many linter problems that c…
FrancescoPezzella Aug 26, 2026
49b5b03
Fixed a TODO bug with Snake_Case, file names with 2+ words were not c…
FrancescoPezzella Aug 27, 2026
7511b92
Extended TypeVarCheck to fully modernize TypeVar/ParamSpec/TypeVarTup…
FrancescoPezzella Aug 28, 2026
16f8986
Added a Python-version gate to TypeVarCheck (PEP 695 conversion only …
FrancescoPezzella Aug 28, 2026
40e6cc6
Extracted type_var_domain.py (TypeVar/ParamSpec/TypeVarTuple domain m…
FrancescoPezzella Aug 31, 2026
f72ef2d
Fixed the 6 pyright strict findings in type_var_check.py/type_var_dom…
FrancescoPezzella Aug 31, 2026
7f8d3a5
Fix silent corruption when two rewrites target the same node (ast_rew…
FrancescoPezzella Aug 31, 2026
55a865c
Fix silent corruption when two rewrites target the same node (ast_rew…
FrancescoPezzella Aug 31, 2026
e05e857
Fix TypeVarCheck corrupting or losing code during PEP 695 conversion
FrancescoPezzella Sep 1, 2026
8bb35b1
Ruff: Fixed and enabled (W)hitespace rule
FrancescoPezzella Sep 1, 2026
c81f2db
Fixed ruff releated formatting issues
FrancescoPezzella Sep 1, 2026
7f4f88c
Applied ruff fixes
FrancescoPezzella Sep 2, 2026
adcba0f
Ruff fixes
FrancescoPezzella Sep 7, 2026
876b53d
Add migration-type-recipes.py CLI for TypeVarCheck
FrancescoPezzella Sep 8, 2026
87cf9e1
CLI - both typevar and typevartuplecheck integrated
FrancescoPezzella Sep 8, 2026
95e643b
Add Step/run_steps, refactor TypeVarCheck.check() to use it
FrancescoPezzella Sep 9, 2026
b240539
Removed dead code (which became irrelevant some ago), cleaned up some…
FrancescoPezzella Sep 9, 2026
992afd4
Delegate unused-import cleanup to ruff F401 (CLI will call Ruff, no n…
FrancescoPezzella Sep 9, 2026
8999a38
Rewrite CLI: remove dry-run (issues, easier to remove, git diff alrea…
FrancescoPezzella Sep 9, 2026
59c4359
Quote TYPE_CHECKING-only annotation, scope UP037 noqa to one line
FrancescoPezzella Sep 10, 2026
e0840ed
Ruff unsafe fix
FrancescoPezzella Sep 11, 2026
504fc0a
'--review' now gives more information to the user regarding Type reci…
FrancescoPezzella Sep 11, 2026
6696dc1
Removed code duplication, fixed incorrect paths to files (before refa…
FrancescoPezzella Sep 11, 2026
ae7ee5e
Fixed a bug with the correct Python version not being identified by t…
FrancescoPezzella Sep 11, 2026
ffdfe1f
Updated outdated Docs - removed references to deleted Python Kind Map
FrancescoPezzella Sep 14, 2026
557f9ef
Added feedback when processing each file with the Migration tool.
FrancescoPezzella Sep 14, 2026
76f3c0a
Forced UTF until becomes Py 3.15 default
FrancescoPezzella Sep 16, 2026
ed68dd6
New test, and cleaned up some old comments for tests
FrancescoPezzella Sep 17, 2026
83c962c
Deleted incorrect files added during the rebase
FrancescoPezzella Sep 21, 2026
16a40e0
Rebase mistakes-
FrancescoPezzella Sep 21, 2026
61add31
Last rebase mistake
FrancescoPezzella Sep 21, 2026
e61ddf7
Add missing docstrings, reword existing ones, add missing import
FrancescoPezzella Sep 21, 2026
f833442
TypeVar issues
FrancescoPezzella Sep 21, 2026
f17d2aa
Add project-wide import safety to TypeVar localization
FrancescoPezzella Sep 22, 2026
8ab5b82
Add missing docstrings to TypingRecipe related tests
FrancescoPezzella Sep 23, 2026
f9d310a
New test that shows a fault in the CLI
FrancescoPezzella Sep 23, 2026
40708e7
Fix project_root wiring and relative paths in TypeVar import safety
FrancescoPezzella Sep 23, 2026
d4446d5
Clean up comments and doc strings
FrancescoPezzella Sep 23, 2026
c498d74
Add TODOs to migration tool
FrancescoPezzella Sep 23, 2026
9241e76
Access TypeVars as model attributes
FrancescoPezzella Sep 23, 2026
4ff4647
Adjust CLI message and resolve path
FrancescoPezzella Sep 23, 2026
03d9b5b
Fix outdated references
FrancescoPezzella Sep 23, 2026
fc223f9
Cleaner docstring
FrancescoPezzella Sep 24, 2026
7a9c54c
Tool no longer looks for a Python Version in the project: was suspect…
FrancescoPezzella Sep 24, 2026
779c062
Removed failing test: CI/CD uses Linux environment (which is UTF-8 by…
FrancescoPezzella Sep 24, 2026
cc9595c
Added an optional cmd for the user to not run Ruff with --no-ruff. Th…
FrancescoPezzella Sep 25, 2026
6cb5df7
Refuse to localize a TypeVar whose origin imports its constructor con…
FrancescoPezzella Sep 30, 2026
4c5756e
Revert changes in ast_refactor_actions (handled in a separate PR)
FrancescoPezzella Oct 2, 2026
3e5dcad
TODOs for 2 bugs
FrancescoPezzella Oct 2, 2026
3216a7e
Remove disabled Ruff rule ignores, Clean up docstring and comment
FrancescoPezzella Oct 2, 2026
925dd36
Docstring wording
FrancescoPezzella Oct 5, 2026
e70ecc7
Remove TypeVarTupleCheck and its related tests have been removed or o…
FrancescoPezzella Oct 5, 2026
b301ae8
Add tests with xfail regarding multilines and multiple Type Vars bein…
FrancescoPezzella Oct 5, 2026
0efde57
Remove duplicate code
FrancescoPezzella Oct 6, 2026
866fe7b
Verify bug with TODO and fix another bug
FrancescoPezzella Oct 6, 2026
3c14c2b
TODO for a bug
FrancescoPezzella Oct 6, 2026
6ad5be0
TODO for another bug
FrancescoPezzella Oct 6, 2026
74f063f
Both Step2 and Step3 from type_var_check no longer delete orphaned de…
FrancescoPezzella Oct 6, 2026
872743a
Remove same name being shown twice in the CLI report and remove low v…
FrancescoPezzella Oct 6, 2026
9f7d0e7
Remove duplicate, low value, X is not present type tests
FrancescoPezzella Oct 7, 2026
7cc2a18
Test with multiple TypeVars and their output order
FrancescoPezzella Oct 7, 2026
874562e
Fix test
FrancescoPezzella Oct 7, 2026
73fec1d
Remove `USED_OUTSIDE_FUNCTION` as a reason for not converting Type Pa…
FrancescoPezzella Oct 7, 2026
843e18f
Combined Generic definition for 2 Generic related unsafe rules in typ…
FrancescoPezzella Oct 7, 2026
450d164
Remove `ORIGIN_CLASS_IS_GENERIC_OVER_NAME` and add `DECLARATION_NAME_…
FrancescoPezzella Oct 7, 2026
91a7a2d
Remove 'ORIGIN_MODULE_EXPORTS_NAME' rule. TypeVar can be localized sa…
FrancescoPezzella Oct 7, 2026
e02ce00
Big with TYPE_CHECKING fixed, test adjusted, text corrected
FrancescoPezzella Oct 7, 2026
679ba00
TypeVarCheck now conservs default= and converts it with Py 3.13+. Whe…
FrancescoPezzella Oct 8, 2026
eac917a
Clean up comments and docstrings
FrancescoPezzella Oct 8, 2026
b21e82f
Clean up tests
FrancescoPezzella Oct 8, 2026
6724e03
Docuement and test 3 bugs
FrancescoPezzella Oct 8, 2026
dd2eb1b
Lint errors and fixes for tests
FrancescoPezzella Oct 9, 2026
f4c96be
Lint/ruff errors
FrancescoPezzella Oct 9, 2026
ef7a472
Bug: Localize all TypeVars imported by one statement in a single edit
FrancescoPezzella Oct 9, 2026
9c94254
Re-anchor a relatively imported TypeVar constructor on the localized …
FrancescoPezzella Oct 9, 2026
2511691
Add any other form of `__all__ = [...]` as a Non-Goal (no patterns de…
FrancescoPezzella Oct 9, 2026
726696e
Replace narrowed_import_text with ast.unparse in TypeVarCheck._locali…
FrancescoPezzella Oct 9, 2026
fe08e71
Bring #202 within the lint budget
FrancescoPezzella Oct 12, 2026
16de3cd
TODOs regarding Py 3.15 lazy imports
FrancescoPezzella Oct 12, 2026
649733e
Add the official TNO copyright notice to new files
FrancescoPezzella Oct 16, 2026
0144dbf
Update type parameter modernization documentation references
FrancescoPezzella Oct 16, 2026
7cd371b
Port TypeVarCheck to libcst
FrancescoPezzella Oct 16, 2026
2f42afe
Track the multi-line string re-indentation and PatternMatch placehold…
FrancescoPezzella Oct 13, 2026
e44580b
Track the TypeVarCheck bugs found in review in TODOs, and explain why…
FrancescoPezzella Oct 13, 2026
a5c7d2f
Document six more TypeVarCheck non-goals and drop their TODOs and xfa…
FrancescoPezzella Oct 13, 2026
16234e3
Temporary UTF-8 fix; TODO drops the explicit encoding with Python 3.1…
FrancescoPezzella Oct 13, 2026
d742303
Skip functions that would mix legacy and PEP 695 type parameters. A f…
FrancescoPezzella Oct 13, 2026
129bc8f
Bind each TypeVar to the function whose signature uses it. A TypeVar …
FrancescoPezzella Oct 13, 2026
9e12731
Place localized TypeVar declarations after the import block and run r…
FrancescoPezzella Oct 14, 2026
c43dd9b
Copy the trailing comment of a localized TypeVar declaration
FrancescoPezzella Oct 14, 2026
21c8f00
Import the names a localized TypeVar uses from where the origin gets …
FrancescoPezzella Oct 14, 2026
d38df3e
List files in the TypeVar migration report with a blank line between …
FrancescoPezzella Oct 19, 2026
a9dfd76
Add per-kind and ranked unsafe-reason summary tables to the TypeVar m…
FrancescoPezzella Oct 19, 2026
a451778
Report a type parameter still used by a generic class even when its f…
FrancescoPezzella Oct 19, 2026
8ef07c9
Convert TypeVars declared with covariant=/contravariant= when only fu…
FrancescoPezzella Oct 19, 2026
a6c0428
List a type parameter that is localized and then removed only as an u…
FrancescoPezzella Oct 19, 2026
fa20404
Rename the declaration-name-unavailable reason to name-not-at-module-…
FrancescoPezzella Oct 19, 2026
c6c1c75
Reject --py below 3.12 and remove the PEP 695 version gate. Minimum s…
FrancescoPezzella Oct 20, 2026
18a2a68
Add --ignore-localize to keep the imports of shared type parameter fi…
FrancescoPezzella Oct 20, 2026
97826cf
Reword the conditional-origin-import reason to cover TYPE_CHECKING bl…
FrancescoPezzella Oct 20, 2026
1b91cb7
Make the type-parameter CLI's closing commit message list what was co…
FrancescoPezzella Oct 20, 2026
42561a2
Replace --ignore-localize with --ignore, which leaves the named files…
FrancescoPezzella Oct 20, 2026
c8f8af9
Add --no-localization to keep the imports of project type parameters …
FrancescoPezzella Oct 20, 2026
004ea24
Group the manual-review section of the migration report by reason and…
FrancescoPezzella Oct 20, 2026
35ff34f
Add --second-pass to reprocess files that kept a declaration only bec…
FrancescoPezzella Oct 20, 2026
0d689ab
Add the Refactoring recipes and rejected recipes docs and the Type pa…
FrancescoPezzella Oct 16, 2026
24b773c
Port TypeVarCheck to libcst
FrancescoPezzella Oct 16, 2026
190c9ea
Add per-kind and ranked unsafe-reason summary tables to the TypeVar m…
FrancescoPezzella Oct 19, 2026
21aaeb7
Report a type parameter still used by a generic class even when its f…
FrancescoPezzella Oct 19, 2026
cdb885a
Convert TypeVars declared with covariant=/contravariant= when only fu…
FrancescoPezzella Oct 19, 2026
44c2508
Reject --py below 3.12 and remove the PEP 695 version gate. Minimum s…
FrancescoPezzella Oct 20, 2026
ee77157
Add --ignore-localize to keep the imports of shared type parameter fi…
FrancescoPezzella Oct 20, 2026
7be93dd
Make the type-parameter CLI's closing commit message list what was co…
FrancescoPezzella Oct 20, 2026
487de69
Replace --ignore-localize with --ignore, which leaves the named files…
FrancescoPezzella Oct 20, 2026
c1f67b9
Add --no-localization to keep the imports of project type parameters …
FrancescoPezzella Oct 20, 2026
ee47db0
Group the manual-review section of the migration report by reason and…
FrancescoPezzella Oct 20, 2026
f64b24e
Rename the TypeVar recipe to TypeParameterCheck (type_parameter_check…
FrancescoPezzella Oct 21, 2026
5e7affb
Split convert_declared_typevars and _place_localizations into smaller…
FrancescoPezzella Oct 21, 2026
e575156
Move the generic import-statement helpers into utils/import_resolutio…
FrancescoPezzella Oct 21, 2026
78f7b36
Register the independent refusal checks of the type-parameter recipe …
FrancescoPezzella Oct 21, 2026
5341a05
Split type_parameter_rules.py into type_parameter_declarations.py, ty…
FrancescoPezzella Oct 21, 2026
a786daf
Add direct tests for the cst_utils helpers and for declaration_argume…
FrancescoPezzella Oct 21, 2026
88bef08
Read __all__ with libcst's GatherExportsVisitor so annotated and += f…
FrancescoPezzella Oct 23, 2026
440f560
Inline string_value into declaration_argument_names, its only caller,…
FrancescoPezzella Oct 23, 2026
5a4a675
Remove declares_type_param: libcst's scope analysis already excludes …
FrancescoPezzella Oct 23, 2026
d1431c8
Move trailing_of_sole_statement to cst_utils, where the other libcst …
FrancescoPezzella Oct 23, 2026
e44782b
Extract the decision of which imported type parameters to localize fr…
FrancescoPezzella Oct 23, 2026
a143ba2
Rewrite the TypeParameterCheck docstrings in short, behavioural form …
FrancescoPezzella Oct 25, 2026
6d47170
Add comment regarding Ruff's UP046
FrancescoPezzella Oct 26, 2026
9e907b1
Add strict xfail tests and documentation for the UTF-8 BOM, non-UTF-8…
FrancescoPezzella Oct 26, 2026
c6d921c
Comment regarding TypeVarTuple in 3.15
FrancescoPezzella Oct 26, 2026
10695c8
Restore the type parameter recipe, CLI and CLI test files to their pr…
FrancescoPezzella Oct 29, 2026
4dfde50
Replace the vacuous hypothesmith smoke test of TypeParameterCheck wit…
FrancescoPezzella Oct 29, 2026
90750ab
Rebase mistake fix
FrancescoPezzella Oct 30, 2026
4511fb7
Fix pyright issues
FrancescoPezzella Oct 30, 2026
71dd9bc
Remove UnsafeRule.doc_anchor and its test: the migration report links…
FrancescoPezzella Nov 3, 2026
b8a17a6
Skip files that libcst fails to parse with CSTLogicError when collect…
FrancescoPezzella Nov 4, 2026
8d6ab2c
Run ruff's UP049 in the CLI's final ruff pass, so converted type para…
FrancescoPezzella Nov 4, 2026
ce0254f
Rename migration-type-recipes.py to migration_type_recipes.py
FrancescoPezzella Nov 4, 2026
166ccdc
Add missing init file
FrancescoPezzella Nov 4, 2026
14a0a57
Renamed everything except for the file before, oopsie
FrancescoPezzella Nov 4, 2026
15331ee
Run ruff format after the CLI's ruff check --fix pass, so modified fi…
FrancescoPezzella Nov 4, 2026
0496ce7
Fix pyright issue
FrancescoPezzella Nov 4, 2026
3ab5d5d
Fix pyright issue P2
FrancescoPezzella Nov 4, 2026
8d69d67
Rebase fix
FrancescoPezzella Nov 5, 2026
d54fd45
Run the CLI's ruff pass through ruff_utils (run_ruff_import_cleanup a…
FrancescoPezzella Nov 5, 2026
19769c0
Remove unrelated type fixes
FrancescoPezzella Nov 5, 2026
c00af6b
Made report message in CLI clearer by removing an unneeded line.
FrancescoPezzella Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/developer/feature-test-map/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ https://github.com/TNO/Renaissance.Py/blob/main/LICENSE
- `test/recipes/test_python_refactoring.py`
- `test/utils/test_cst_utils.py`
- `test/utils/test_import_resolution.py`
- `test/utils/test_ruff_utils.py`
- `test/rejuvenation/test_migration_type_recipes.py`
- **Code file(s):** `src/renaissance/recipes/type_parameter_check.py`, `src/renaissance/recipes/type_parameter_rules.py`,
`src/renaissance/recipes/type_parameter_declarations.py`, `src/renaissance/recipes/type_parameter_localization.py`,
`src/renaissance/recipes/type_parameter_uses.py`,
`src/renaissance/recipes/step_runner.py`,
`src/renaissance/recipes/python_refactoring.py`,
`src/renaissance/utils/import_resolution.py`, `src/renaissance/utils/cst_utils.py`,
`src/renaissance/utils/ruff_utils.py`,
`src/rejuvenation/migration_type_recipes.py`
8 changes: 3 additions & 5 deletions docs/developer/modules/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ safely cover. This page covers `TypeParameterCheck`, the recipe behind
names each project file imports from the others.
- `src/renaissance/utils/cst_utils.py`: a module's top-level statements, the names they read or bind and the comment
trailing a statement's line.

<!-- TODO: FrancescoPezzella - list ruff_utils.py here once a recipe uses run_ruff_import_cleanup (#111):
- `src/renaissance/utils/ruff_utils.py`: `run_ruff_import_cleanup`, which removes unused imports and sorts the imports
of the files a recipe changed, with ruff. -->

- `src/renaissance/utils/ruff_utils.py`: `run_ruff_import_cleanup` and `run_ruff_format`, which the CLI runs on the
files the recipe changed. The first removes unused imports and sorts the imports, the second formats the files.

## Public entry points

- `TypeParameterCheck.check()` (and `run()`): runs the three phases through `run_steps`, committing to disk between them.
Expand Down
9 changes: 4 additions & 5 deletions docs/user/features/type-parameter-modernization.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,15 @@ run the tool again.
- `test/recipes/test_python_refactoring.py`
- `test/utils/test_cst_utils.py`
- `test/utils/test_import_resolution.py`
- `test/utils/test_ruff_utils.py`
- `test/rejuvenation/test_migration_type_recipes.py`

## Implemented by code modules

- [Refactoring recipes](../../developer/modules/recipes.md)
- `src/renaissance/recipes/type_parameter_check.py`, `type_parameter_rules.py`, `type_parameter_declarations.py`,
`type_parameter_localization.py`, `type_parameter_uses.py`, `step_runner.py` and `python_refactoring.py`.
- `src/renaissance/utils/import_resolution.py` and `cst_utils.py`
- `src/renaissance/utils/import_resolution.py`, `cst_utils.py` and `ruff_utils.py`
- `src/rejuvenation/migration_type_recipes.py` (the CLI)

## API entry points
Expand All @@ -432,12 +433,10 @@ python src/rejuvenation/migration_type_recipes.py <path> --py MAJOR.MINOR \
- `--second-pass`: process again only the files that kept a declaration because another file imported it when the run
started, and merge the result into the same report.

After the recipe, the CLI runs `ruff check --fix --select F401,I001,UP049` on the changed files. This removes **every**
After the recipe, the CLI runs `ruff check --fix --select F401,I001` on the changed files. This removes **every**
unused import in them, including ones that were unused before (such as `from typing import TypeVar` after the
declaration is gone). It also merges and sorts **every** import block in them, including imports that were unsorted
before, using the `ruff` settings of the project. It removes the leading underscores of **every** PEP 695 type
parameter in them, so `def f[_T]` becomes `def f[T]`, unless the new name would shadow another one. Docstrings,
comments and the report keep the old name. The project's `select` and `ignore` lists do not apply to these three
before, using the `ruff` settings of the project. The project's `select` and `ignore` lists do not apply to these two
rules. Then it runs `ruff format` on the same files, which reformats **every** line in them with the project's
`ruff format` settings, not only the changed ones. `ruff` must be installed in the same environment. Files are changed
directly, so run it on a git checkout.
Expand Down
Loading
Loading