diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 68ac2a9b1900..23fa5aad3bb8 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -7,13 +7,13 @@ import ctypes import mmap import pickle import sys -from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet +from collections.abc import Awaitable, Callable, Hashable, Iterable, Set as AbstractSet from os import PathLike from types import FrameType, TracebackType from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union from typing_extensions import Final, Literal, LiteralString, TypeAlias, final -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _KT_co = TypeVar("_KT_co", covariant=True) _KT_contra = TypeVar("_KT_contra", contravariant=True) _VT = TypeVar("_VT") diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 9a1cfa407a1a..65627ce9e177 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -27,7 +27,7 @@ from _typeshed import ( SupportsTrunc, SupportsWrite, ) -from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized +from collections.abc import Awaitable, Callable, Hashable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from types import CodeType, TracebackType, _Cell @@ -63,7 +63,7 @@ _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_contra = TypeVar("_T_contra", contravariant=True) _R_co = TypeVar("_R_co", covariant=True) -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _VT = TypeVar("_VT") _S = TypeVar("_S") _T1 = TypeVar("_T1") diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index f524293af054..b8a0eb5b7766 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -10,6 +10,7 @@ if sys.version_info >= (3, 9): if sys.version_info >= (3, 10): from collections.abc import ( Callable, + Hashable, ItemsView, Iterable, Iterator, @@ -30,7 +31,7 @@ _S = TypeVar("_S") _T = TypeVar("_T") _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _VT = TypeVar("_VT") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index efee27f91265..25965d5e1d00 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -2,7 +2,7 @@ import queue import sys import threading from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence +from collections.abc import Callable, Hashable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence from types import TracebackType from typing import Any, AnyStr, ClassVar, Generic, TypeVar, overload from typing_extensions import SupportsIndex, TypeAlias @@ -22,7 +22,7 @@ if sys.version_info >= (3, 9): from types import GenericAlias _T = TypeVar("_T") -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _VT = TypeVar("_VT") class Namespace: diff --git a/stdlib/types.pyi b/stdlib/types.pyi index d4069c672737..06a9adf31dee 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -6,6 +6,7 @@ from collections.abc import ( Callable, Coroutine, Generator, + Hashable, ItemsView, Iterable, Iterator, @@ -62,7 +63,7 @@ _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") _T_co = TypeVar("_T_co", covariant=True) _T_contra = TypeVar("_T_contra", contravariant=True) -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _VT_co = TypeVar("_VT_co", covariant=True) _V_co = TypeVar("_V_co", covariant=True) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 8d3531941d56..b2d8d775138c 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -244,7 +244,7 @@ else: # These type variables are used by the container types. _S = TypeVar("_S") -_KT = TypeVar("_KT") # Key type. +_KT = TypeVar("_KT", bound=Hashable) # Key type. _VT = TypeVar("_VT") # Value type. _T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers. _V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers. diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 583dfdb69d6b..d04936805eae 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -10,7 +10,7 @@ from _weakref import ( ref as ref, ) from _weakrefset import WeakSet as WeakSet -from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping +from collections.abc import Callable, Hashable, Iterable, Iterator, Mapping, MutableMapping from typing import Any, Generic, TypeVar, overload from typing_extensions import ParamSpec @@ -33,7 +33,7 @@ __all__ = [ _T = TypeVar("_T") _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") -_KT = TypeVar("_KT") +_KT = TypeVar("_KT", bound=Hashable) _VT = TypeVar("_VT") _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) _P = ParamSpec("_P")