Skip to content

Commit db1368d

Browse files
cdce8pmypybot
authored andcommitted
Revert Use contravariant type variable in Container
1 parent d0b140c commit db1368d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

mypy/typeshed/stdlib/typing.pyi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,17 +640,14 @@ class AsyncGenerator(AsyncIterator[_YieldT_co], Protocol[_YieldT_co, _SendT_cont
640640
) -> Coroutine[Any, Any, _YieldT_co]: ...
641641
def aclose(self) -> Coroutine[Any, Any, None]: ...
642642

643-
_ContainerT_contra = TypeVar("_ContainerT_contra", contravariant=True, default=Any)
644-
645643
@runtime_checkable
646-
class Container(Protocol[_ContainerT_contra]):
644+
class Container(Protocol[_T_co]):
647645
# This is generic more on vibes than anything else
648646
@abstractmethod
649-
def __contains__(self, x: _ContainerT_contra, /) -> bool: ...
647+
def __contains__(self, x: object, /) -> bool: ...
650648

651649
@runtime_checkable
652-
class Collection(Iterable[_T_co], Container[Any], Protocol[_T_co]):
653-
# Note: need to use Container[Any] instead of Container[_T_co] to ensure covariance.
650+
class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
654651
# Implement Sized (but don't have it as a base class).
655652
@abstractmethod
656653
def __len__(self) -> int: ...

0 commit comments

Comments
 (0)