Skip to content

Commit 2969922

Browse files
authored
Fix intransitive subtyping issue with SupportsGetItem (#8785)
See python/mypy#13713 for details
1 parent 4746f9b commit 2969922

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stdlib/_typeshed/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ctypes
77
import mmap
88
import pickle
99
import sys
10-
from collections.abc import Awaitable, Callable, Container, Iterable, Set as AbstractSet
10+
from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet
1111
from os import PathLike
1212
from types import FrameType, TracebackType
1313
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union
@@ -118,7 +118,8 @@ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
118118
def __getitem__(self, __key: _KT) -> _VT_co: ...
119119

120120
# stable
121-
class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]):
121+
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
122+
def __contains__(self, __x: object) -> bool: ...
122123
def __getitem__(self, __key: _KT_contra) -> _VT_co: ...
123124

124125
# stable

stdlib/typing.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
447447

448448
@runtime_checkable
449449
class Container(Protocol[_T_co]):
450+
# This is generic more on vibes than anything else
450451
@abstractmethod
451452
def __contains__(self, __x: object) -> bool: ...
452453

0 commit comments

Comments
 (0)