Skip to content

Add undocumented _mapping to collections.abc MappingView, KeysView, ValuesView, ItemsView #7583

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

Closed
wants to merge 7 commits into from
Closed
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
27 changes: 20 additions & 7 deletions stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -14,20 +15,20 @@ 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,
Reversible as Reversible,
Sequence as Sequence,
Sized as Sized,
TypeVar,
ValuesView as ValuesView,
ValuesView as _ValuesView,
)
from typing_extensions import final

Expand Down Expand Up @@ -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
3 changes: 0 additions & 3 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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__
Expand Down
6 changes: 0 additions & 6 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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__
Expand Down