ruff
[`pyupgrade`] Add rules to use PEP 695 generics in classes and functions (`UP046`, `UP047`)
#15565
Merged

[`pyupgrade`] Add rules to use PEP 695 generics in classes and functions (`UP046`, `UP047`) #15565

ntBre merged 77 commits into main from brent/pep695-generics
ntBre
ntBre rename old up040 tests
86146c73
ntBre handle simplest generic class case
72f966d4
ntBre run new test and add snap
7d0c1f9b
ntBre extend rule to TypeVarTuple
12874e84
ntBre extend the rule to ParamSpec
b27b281c
ntBre factor out From<TypeVar> for TypeParam
40504868
ntBre handle generic function with TypeParams
a58cd262
ntBre preserve comments in functions
32401732
ntBre use Edit::insertion for classes too
3cadd126
ntBre factor out fmt_type_vars, sort by kind
d2dabc05
ntBre test that comments are preserved
278286b7
ntBre test that methods are not currently changed, but add todo
3af94282
ntBre clippy
81766299
ntBre separate up040 and (new) up046 with shared super module
ca928689
ntBre finish separating UP040 and new UP046
9ad96420
ntBre Revert "rename old up040 tests"
ea0e2762
ntBre document fmt_type_vars
7d616f81
ntBre tidy Violation code after split
c6c434cb
ntBre ntBre added rule
github-actions
ntBre ntBre added preview
AlexWaygood AlexWaygood requested a review from AlexWaygood AlexWaygood 237 days ago
ntBre
dhruvmanila
MichaReiser
MichaReiser approved these changes on 2025-01-20
AlexWaygood
AlexWaygood commented on 2025-01-20
AlexWaygood
ntBre bail out on duplicate type variables
821df964
ntBre delete runtime documentation from type aliases
3891fec7
ntBre preserve order
57c65d84
ntBre import TypeVar and fix mkdocs formatting
9315d279
ntBre rename TypeVarKind -> TypeParamKind and variants
080ab06c
ntBre document and test that multiple base classes are not handled
f27da8d6
ntBre limit class diagnostic to Generic parameter
5997743f
ntBre comment on python version checks
224311b0
ntBre avoid AST names in documentation
1e4c20d0
ntBre TypeParam -> TypeVar in docs
188f26d0
ntBre impl Display for DisplayTypeVar and DisplayTypeVars wrappers
55be0d85
AlexWaygood
AlexWaygood commented on 2025-01-20
ntBre Remove Ord and PartialOrd
01c7c125
ntBre Fix type alias wording
f62a68da
AlexWaygood
ntBre Apply docs suggestions
cfe9c4a4
ntBre factor out `check_type_vars` and check vars.is_empty first
f12036e0
ntBre add `See also` section pointing to `unused-private-type-var`
30a0f045
ntBre update type alias docs around isinstance
933002ed
ntBre add constrained class test
274cf715
ntBre add constrained function test
28d9b4a2
AlexWaygood
ntBre
AlexWaygood
ntBre bail out on `default` for now
bfb0b294
ntBre skip nested classes and functions
e7749eda
ntBre document nesting and `default` limitations
108e5bec
ntBre move shared function and class code to parent module
550fc440
ntBre rename to mod.rs
8f96a269
ntBre separate tests
d2c84eb2
ntBre update rule codes
7326ee34
ntBre rename rules and separate
811e9493
ntBre update ruff schema
450dfd41
ntBre Revert "update ruff schema"
59301517
ntBre only add UP047 to schema (don't remove PLW0101)
4a6dbf18
ntBre ntBre changed the title [`pyupgrade`] Expand UP040 to handle generic functions and classes (`UP040`, `UP046`) [`pyupgrade`] Add rules to use PEP 695 generics in classes and functions (`UP046`, `UP047`) 236 days ago
ntBre
MichaReiser
AlexWaygood
AlexWaygood commented on 2025-01-21
AlexWaygood
ntBre Simplify `check_type_vars`
b9e03bcf
ntBre Fix many documentation issues
1531bf12
ntBre
ntBre fix typo
96c36dd4
ntBre update see also sections
07d3ca34
AlexWaygood
AlexWaygood
AlexWaygood commented on 2025-01-21
ntBre track default value on TypeVar but don't use it yet
39d0a5b2
ntBre only emit diagnostics if there's an unknown type in class def
e0f12518
ntBre mark fixes as unsafe, document them, and test
d034f627
ntBre add a special case for typing.AnyStr
d55e2aed
ntBre clippy
c3f38585
ntBre re-unify visitors
cee09a48
ntBre use unsafe_edit
550cf6da
ntBre
ntBre fix typo
06993aa2
ntBre add a test with multiple generics
9fadf469
AlexWaygood
AlexWaygood commented on 2025-01-21
AlexWaygood
AlexWaygood commented on 2025-01-21
AlexWaygood
AlexWaygood commented on 2025-01-21
AlexWaygood
AlexWaygood commented on 2025-01-21
AlexWaygood
AlexWaygood
AlexWaygood commented on 2025-01-22
ntBre slightly more realistic class code
6c696f1a
ntBre slightly more realistic function code
a15703e5
ntBre update snapshots
9948059e
ntBre fix imports, make Multiple -> MultipleBaseClasses
4500160b
ntBre fix AnyStr handling
c6abe126
ntBre add UP040 tests with `default` and bail early
8bc0d9eb
ntBre check that AnyStr constraints are bound to builtins
bfdb4915
ntBre add note on type checkers
c9753858
ntBre update module comment
f3e66933
ntBre move str shadow test to separate fixture
e2c92ffc
AlexWaygood
AlexWaygood approved these changes on 2025-01-22
ntBre clarify comment
fa1007a9
ntBre fix tuple
76d03b23
ntBre update snapshots
e47f4787
ntBre update module names to match rule names
196b9057
ntBre simplify with ?
35a1c7e2
AlexWaygood
AlexWaygood approved these changes on 2025-01-22
ntBre fix module names in docs
971cb09d
ntBre ntBre merged bb6fb468 into main 234 days ago
ntBre ntBre deleted the brent/pep695-generics branch 234 days ago

Login to write a write a comment.

Login via GitHub

Assignees
No one assigned
Labels
Milestone