mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
[flake8-pyi
] Remove type parameter correctly when it is the last (PYI019
) (#15854)
This commit is contained in:
parent
ce769f6ae2
commit
b2cb757fa8
4 changed files with 28 additions and 1 deletions
|
@ -112,3 +112,7 @@ def shadowed_type():
|
|||
class SubscriptReturnType:
|
||||
@classmethod
|
||||
def m[S](cls: type[S]) -> type[S]: ... # PYI019, but no autofix (yet)
|
||||
|
||||
|
||||
class PEP695TypeParameterAtTheVeryEndOfTheList:
|
||||
def f[T, S](self: S) -> S: ...
|
||||
|
|
|
@ -430,7 +430,7 @@ fn remove_typevar_declaration(type_params: Option<&TypeParams>, name: &str) -> O
|
|||
// [A, B, C]
|
||||
// ^^^ Remove this
|
||||
let previous_range = parameters[index - 1].range();
|
||||
TextRange::new(previous_range.end(), typevar_range.start())
|
||||
TextRange::new(previous_range.end(), typevar_range.end())
|
||||
};
|
||||
|
||||
Some(Edit::range_deletion(range))
|
||||
|
|
|
@ -224,3 +224,11 @@ PYI019.pyi:114:31: PYI019 Methods like `m` should return `Self` instead of a cus
|
|||
| ^^^^^^^ PYI019
|
||||
|
|
||||
= help: Replace with `Self`
|
||||
|
||||
PYI019.pyi:118:29: PYI019 Methods like `f` should return `Self` instead of a custom `TypeVar`
|
||||
|
|
||||
117 | class PEP695TypeParameterAtTheVeryEndOfTheList:
|
||||
118 | def f[T, S](self: S) -> S: ...
|
||||
| ^ PYI019
|
||||
|
|
||||
= help: Replace with `Self`
|
||||
|
|
|
@ -444,3 +444,18 @@ PYI019.pyi:114:31: PYI019 Methods like `m` should return `Self` instead of a cus
|
|||
| ^^^^^^^ PYI019
|
||||
|
|
||||
= help: Replace with `Self`
|
||||
|
||||
PYI019.pyi:118:29: PYI019 [*] Methods like `f` should return `Self` instead of a custom `TypeVar`
|
||||
|
|
||||
117 | class PEP695TypeParameterAtTheVeryEndOfTheList:
|
||||
118 | def f[T, S](self: S) -> S: ...
|
||||
| ^ PYI019
|
||||
|
|
||||
= help: Replace with `Self`
|
||||
|
||||
ℹ Safe fix
|
||||
115 115 |
|
||||
116 116 |
|
||||
117 117 | class PEP695TypeParameterAtTheVeryEndOfTheList:
|
||||
118 |- def f[T, S](self: S) -> S: ...
|
||||
118 |+ def f[T](self) -> Self: ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue