diff --git a/stdlib/_collections_abc.pyi b/stdlib/_collections_abc.pyi index bd8d35641b37..da4cb24cb5da 100644 --- a/stdlib/_collections_abc.pyi +++ b/stdlib/_collections_abc.pyi @@ -2,6 +2,7 @@ import sys from types import MappingProxyType from typing import ( AbstractSet as Set, + Any, AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, @@ -14,12 +15,12 @@ from typing import ( Generator as Generator, Generic, Hashable as Hashable, - ItemsView as ItemsView, + ItemsView as _ItemsView, Iterable as Iterable, Iterator as Iterator, - KeysView as KeysView, + KeysView as _KeysView, Mapping as Mapping, - MappingView as MappingView, + MappingView as _MappingView, MutableMapping as MutableMapping, MutableSequence as MutableSequence, MutableSet as MutableSet, @@ -27,7 +28,7 @@ from typing import ( Sequence as Sequence, Sized as Sized, TypeVar, - ValuesView as ValuesView, + ValuesView as _ValuesView, ) from typing_extensions import final @@ -63,19 +64,31 @@ _KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers. _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers. @final -class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented +class dict_keys(_KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented if sys.version_info >= (3, 10): @property def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final -class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented +class dict_values(_ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented if sys.version_info >= (3, 10): @property def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... @final -class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented +class dict_items(_ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented if sys.version_info >= (3, 10): @property def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ... + +class MappingView(_MappingView): + _mapping: Mapping[Any, Any] # undocumented + +class KeysView(_KeysView[_KT_co], Generic[_KT_co]): + _mapping: Mapping[_KT_co, Any] # undocumented + +class ValuesView(_ValuesView[_VT_co], Generic[_VT_co]): + _mapping: Mapping[Any, _VT_co] # undocumented + +class ItemsView(_ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): + _mapping: Mapping[_KT_co, _VT_co] # undocumented diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 994cd25a0095..e7f04ba4a332 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -3,9 +3,6 @@ _collections_abc.AsyncGenerator.ag_await _collections_abc.AsyncGenerator.ag_code _collections_abc.AsyncGenerator.ag_frame _collections_abc.AsyncGenerator.ag_running -_collections_abc.ItemsView.__reversed__ -_collections_abc.KeysView.__reversed__ -_collections_abc.ValuesView.__reversed__ # These are not positional-only at runtime, but we treat them # as positional-only to match dict. diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index f8466db95d3a..2579a5101879 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -2,9 +2,6 @@ _collections_abc.AsyncGenerator.ag_await _collections_abc.AsyncGenerator.ag_code _collections_abc.AsyncGenerator.ag_frame _collections_abc.AsyncGenerator.ag_running -_collections_abc.ItemsView.__reversed__ -_collections_abc.KeysView.__reversed__ -_collections_abc.ValuesView.__reversed__ _dummy_threading ast.Bytes.__new__ ast.Ellipsis.__new__ @@ -28,9 +25,6 @@ collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.Callable -collections.ItemsView.__reversed__ -collections.KeysView.__reversed__ -collections.ValuesView.__reversed__ collections.Mapping.__reversed__ # Set to None at runtime for a better error message # Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. collections.Set.__rand__ diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index f09e5171a52a..ec482002bcb5 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -3,9 +3,6 @@ _collections_abc.AsyncGenerator.ag_await _collections_abc.AsyncGenerator.ag_code _collections_abc.AsyncGenerator.ag_frame _collections_abc.AsyncGenerator.ag_running -_collections_abc.ItemsView.__reversed__ -_collections_abc.KeysView.__reversed__ -_collections_abc.ValuesView.__reversed__ _weakref.ProxyType.__reversed__ # Doesn't really exist ast.Bytes.__new__ ast.Ellipsis.__new__ @@ -33,9 +30,6 @@ collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.Callable collections.Mapping.__reversed__ # Set to None at runtime for a better error message -collections.ItemsView.__reversed__ -collections.KeysView.__reversed__ -collections.ValuesView.__reversed__ # Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. collections.Set.__rand__ collections.Set.__ror__