mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## Summary Part of #8771. flake8-pyi will emit a Y018 error for unused TypeVars, ParamSpecs or TypeVarTuples; Ruff currently only emits PYI018 for unused TypeVars. This is my first "proper" Ruff PR -- let me know if there's a better way of doing this! Not sure if the repeated calls to `match_typing_expr()` are ideal. ## Test Plan I manually updated the fixtures to add some unused ParamSpecs and TypeVarTuples, and then updated the snapshots using `cargo insta review`. All tests then passed when run using `cargo test`.
17 lines
427 B
Python
17 lines
427 B
Python
import typing
|
|
import typing_extensions
|
|
from typing import TypeVar
|
|
from typing_extensions import ParamSpec, TypeVarTuple
|
|
|
|
_T = typing.TypeVar("_T")
|
|
_Ts = typing_extensions.TypeVarTuple("_Ts")
|
|
_P = ParamSpec("_P")
|
|
_P2 = typing.ParamSpec("_P2")
|
|
_Ts2 = TypeVarTuple("_Ts2")
|
|
|
|
# OK
|
|
_UsedTypeVar = TypeVar("_UsedTypeVar")
|
|
def func(arg: _UsedTypeVar) -> _UsedTypeVar: ...
|
|
|
|
_A, _B = TypeVar("_A"), TypeVar("_B")
|
|
_C = _D = TypeVar("_C")
|