-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome
Description
We currently offer a diagnostic for unused private type variables like these:
import typing
import typing_extensions
_T = typing.TypeVar("_T")
_Ts = typing_extensions.TypeVarTuple("_Ts")But it would be nice to offer a fix to delete them too. This came up in #15682 because a PYI018 autofix would finish the transformation of pre-PEP-695 code like this:
from typing import Generic, TypeVar
_T = TypeVar("_T")
class Foo(Generic[_T]):
var: _Tto
class Foo[T]:
var: Tby converting from Generic + standalone TypeVar to PEP-695 generics (UP046, renaming the private generic (UP051), and then removing the now-unused private type variable (PYI018 after this issue).
The function implementing this rule can be found here. I think delete_stmt may help with the implementation, with some examples of its usage here and here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome