ruff/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI046.pyi
Alex Waygood cde4a7d7bf
[flake8-pyi] Fix false negative for PYI046 with unused generic protocols (#9405)
I just fixed this false negative in flake8-pyi
(https://github.com/PyCQA/flake8-pyi/pull/460), and then realised ruff
has the exact same bug! Luckily it's a very easy fix.

(The bug is that unused protocols go undetected if they're generic.)
2024-01-05 12:56:04 -06:00

32 lines
448 B
Python

import typing
from typing import Protocol, TypeVar
class _Foo(object, Protocol):
bar: int
class _Bar(typing.Protocol):
bar: int
_T = TypeVar("_T")
class _Baz(Protocol[_T]):
x: _T
# OK
class _UsedPrivateProtocol(Protocol):
bar: int
# Also OK
class _UsedGenericPrivateProtocol(Protocol[_T]):
x: _T
def uses_some_private_protocols(
arg: _UsedPrivateProtocol, arg2: _UsedGenericPrivateProtocol[int]
) -> None: ...