basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

`Container.__contains__` should be generic

Open KotlinIsland opened this issue 9 months ago • 0 comments

@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]

KotlinIsland avatar Feb 21 '25 04:02 KotlinIsland