From 5d9835dc51b0100dd6c4b11d47dcf165bb178eba Mon Sep 17 00:00:00 2001 From: Rohan-Salwan Date: Sat, 27 Nov 2021 13:35:22 +0530 Subject: [PATCH 1/2] fix issue5812 --- stdlib/builtins.pyi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 4d2055feb541..5d5d7be4a370 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -36,8 +36,10 @@ from typing import ( ByteString, Callable, Generic, + ItemsView, Iterable, Iterator, + KeysView, Mapping, MutableMapping, MutableSequence, @@ -57,6 +59,7 @@ from typing import ( Type, TypeVar, Union, + ValuesView, overload, ) from typing_extensions import Literal, SupportsIndex, TypeGuard, final @@ -69,6 +72,8 @@ _T_co = TypeVar("_T_co", covariant=True) _T_contra = TypeVar("_T_contra", contravariant=True) _KT = TypeVar("_KT") _VT = TypeVar("_VT") +_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers. +_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers. _S = TypeVar("_S") _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") @@ -813,6 +818,18 @@ class list(MutableSequence[_T], Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... +class _dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): + if sys.version_info >= (3, 10): + mapping: MappingProxyType[_KT_co, _VT_co] + +class _dict_values(ValuesView[_VT_co], Generic[_VT_co, _KT_co]): + if sys.version_info >= (3, 10): + mapping: MappingProxyType[_KT_co, _VT_co] + +class _dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): + if sys.version_info >= (3, 10): + mapping: MappingProxyType[_KT_co, _VT_co] + class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self: dict[_KT, _VT]) -> None: ... From 6638978d270f5a8771fcb5fd597311076b609bce Mon Sep 17 00:00:00 2001 From: Rohan-Salwan Date: Sat, 27 Nov 2021 13:46:59 +0530 Subject: [PATCH 2/2] error fix --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 5d5d7be4a370..8efc69f30700 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -25,7 +25,7 @@ from _typeshed import ( SupportsWrite, ) from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper -from types import CodeType, TracebackType +from types import CodeType, MappingProxyType, TracebackType from typing import ( IO, AbstractSet,