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