Summary
The documentation of import-private-name (PLC2701) says it “ignores private name imports that are exclusively used in type annotations”, but that doesn’t include imports used in type parameter lists. Those are type annotations too, so it should ignore them too. Example:
$ cat >plc2701.py <<'# EOF'
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from _typeshed import SupportsRichComparison
def f[T: SupportsRichComparison](x: T, y: T):
return x < y or x > y
# EOF
$ ruff --isolated check --select PLC2701 --preview plc2701.py --output-format concise
plc2701.py:4:10: error[PLC2701] Private name import `_typeshed`
Found 1 error.
Version
ruff 0.15.10 (252f761 2026-04-09)
Summary
The documentation of
import-private-name(PLC2701) says it “ignores private name imports that are exclusively used in type annotations”, but that doesn’t include imports used in type parameter lists. Those are type annotations too, so it should ignore them too. Example:Version
ruff 0.15.10 (252f761 2026-04-09)