Skip to content

Fix intransitive subtyping issue with SupportsGetItem #8785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down