8000 covariant key type for `MappingProxyType` · python/typeshed@4961d43 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4961d43

Browse files
committed
covariant key type for MappingProxyType
1 parent a4d3f6f commit 4961d43

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

stdlib/types.pyi

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if sys.version_info >= (3, 13):
6363
_T1 = TypeVar("_T1")
6464
_T2 = TypeVar("_T2")
6565
_KT = TypeVar("_KT")
66+
_KT_co = TypeVar("_KT_co", covariant=True)
6667
_VT_co = TypeVar("_VT_co", covariant=True)
6768

6869
# Make sure this class definition stays roughly in line with `builtins.function`
@@ -302,25 +303,25 @@ class CodeType:
302303
__replace__ = replace
303304

304305
@final
305-
class MappingProxyType(Mapping[_KT, _VT_co]):
306+
class MappingProxyType(Mapping[_KT_co, _VT_co]): # type: ignore[type-var]
306307
__hash__: ClassVar[None] # type: ignore[assignment]
307-
def __new__(cls, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> Self: ...
308-
def __getitem__(self, key: _KT, /) -> _VT_co: ...
309-
def __iter__(self) -> Iterator[_KT]: ...
308+
def __new__(cls, mapping: SupportsKeysAndGetItem[_KT_co, _VT_co]) -> Self: ...
309+
def __getitem__(self, key: _KT_co, /) -> _VT_co: ... # type: ignore[misc]
310+
def __iter__(self) -> Iterator[_KT_co]: ...
310311
def __len__(self) -> int: ...
311312
def __eq__(self, value: object, /) -> bool: ...
312-
def copy(self) -> dict[_KT, _VT_co]: ...
313-
def keys(self) -> KeysView[_KT]: ...
313+
def copy(self) -> dict[_KT_co, _VT_co]: ...
314+
def keys(self) -> KeysView[_KT_co]: ...
314315
def values(self) -> ValuesView[_VT_co]: ...
315-
def items(self) -> ItemsView[_KT, _VT_co]: ...
316+
def items(self) -> ItemsView[_KT_co, _VT_co]: ...
316317
@overload
317-
def get(self, key: _KT, /) -> _VT_co | None: ...
318+
def get(self, key: _KT_co, /) -> _VT_co | None: ... # type: ignore[misc]
318319
@overload
319-
def get(self, key: _KT, default: _VT_co | _T2, /) -> _VT_co | _T2: ...
320+
def get(self, key: _KT_co, default: _VT_co | _T2, /) -> _VT_co | _T2: ... # type: ignore[misc]
320321
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
321-
def __reversed__(self) -> Iterator[_KT]: ...
322-
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
323-
def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
322+
def __reversed__(self) -> Iterator[_KT_co]: ...
323+
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ...
324+
def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ...
324325

325326
class SimpleNamespace:
326327
__hash__: ClassVar[None] # type: ignore[assignment]

0 commit comments

Comments
 (0)
0