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

@@ -12,6 +12,7 @@ from typing import (
BinaryIO,
ByteString,
Callable,
ClassVar,
Container,
Generic,
ItemsView,
@@ -490,7 +491,7 @@ class bytearray(MutableSequence[int], ByteString):
def __iter__(self) -> Iterator[int]: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
@@ -574,7 +575,7 @@ class slice(object):
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
def indices(self, len: int) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -621,7 +622,7 @@ class list(MutableSequence[_T], Generic[_T]):
def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
@@ -683,7 +684,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -725,7 +726,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
__hash__: ClassVar[None] # type: ignore
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ...

View File

@@ -12,6 +12,7 @@ from typing import (
BinaryIO,
ByteString,
Callable,
ClassVar,
Container,
Generic,
ItemsView,
@@ -490,7 +491,7 @@ class bytearray(MutableSequence[int], ByteString):
def __iter__(self) -> Iterator[int]: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
@@ -574,7 +575,7 @@ class slice(object):
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
def indices(self, len: int) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -621,7 +622,7 @@ class list(MutableSequence[_T], Generic[_T]):
def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
@@ -683,7 +684,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
__hash__: None # type: ignore
__hash__: ClassVar[None] # type: ignore
class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -725,7 +726,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
__hash__: ClassVar[None] # type: ignore
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ...