basedmypy
basedmypy copied to clipboard
`Container.__contains__` should be generic
@runtime_checkable
class Container(Protocol[_T_co]):
# This is generic more on vibes than anything else
@abstractmethod
def __contains__(self, x: object, /) -> bool: ...
@runtime_checkable
class Container(Protocol[_T_co]):
@abstractmethod
# must implement safe variance
def __contains__(self, x: _T_co, /) -> bool: ... # type: ignore[unsafe-variance]