From 2969922b68aca8deed88d5337eee903f111b86ef Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Fri, 23 Sep 2022 13:25:15 -0700 Subject: [PATCH] Fix intransitive subtyping issue with SupportsGetItem (#8785) See https://github.com/python/mypy/issues/13713 for details --- stdlib/_typeshed/__init__.pyi | 5 +++-- stdlib/typing.pyi | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c50fe4861..b0ee1f4ad 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -7,7 +7,7 @@ import ctypes import mmap import pickle import sys -from collections.abc import Awaitable, Callable, Container, Iterable, Set as AbstractSet +from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet from os import PathLike from types import FrameType, TracebackType from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union @@ -118,7 +118,8 @@ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): def __getitem__(self, __key: _KT) -> _VT_co: ... # stable -class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]): +class SupportsGetItem(Protocol[_KT_contra, _VT_co]): + def __contains__(self, __x: object) -> bool: ... def __getitem__(self, __key: _KT_contra) -> _VT_co: ... # stable diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 81ba34104..954f47d14 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -447,6 +447,7 @@ class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): @runtime_checkable class Container(Protocol[_T_co]): + # This is generic more on vibes than anything else @abstractmethod def __contains__(self, __x: object) -> bool: ...