Make __hash__ a ClassVar for several classes where it is set to None (#7485)

This commit is contained in:
Alex Waygood
2022-03-19 12:59:10 +00:00
committed by GitHub
parent d9f1f7b81f
commit 4308915e06
5 changed files with 24 additions and 20 deletions

View File

@@ -32,6 +32,7 @@ from typing import (
Awaitable,
BinaryIO,
ByteString,
ClassVar,
Generic,
Iterable,
Iterator,
@@ -656,7 +657,7 @@ class bytearray(MutableSequence[int], ByteString):
def maketrans(__frm: bytes, __to: bytes) -> bytes: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
__hash__: None # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment]
@overload
def __getitem__(self, __i: SupportsIndex) -> int: ...
@overload
@@ -783,7 +784,7 @@ class slice:
def __init__(self, __stop: Any) -> None: ...
@overload
def __init__(self, __start: Any, __stop: Any, __step: Any = ...) -> None: ...
__hash__: None # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment]
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -854,7 +855,7 @@ class list(MutableSequence[_T], Generic[_T]):
def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
__hash__: None # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment]
@overload
def __getitem__(self, __i: SupportsIndex) -> _T: ...
@overload
@@ -922,7 +923,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __iter__(self) -> Iterator[_KT]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT]: ...
__hash__: None # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
@@ -965,7 +966,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, __s: AbstractSet[object]) -> bool: ...
def __ge__(self, __s: AbstractSet[object]) -> bool: ...
def __gt__(self, __s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...