Revert "Remove un-needed __hash__ methods from stdlib (#8465)" (#10426)

Reverts https://github.com/python/typeshed/pull/8465
Fixes https://github.com/python/typeshed/issues/10424
Closes https://github.com/python/typeshed/pull/10425

https://github.com/python/typeshed/pull/8465 caused regressions: see https://github.com/python/typeshed/issues/10424 and https://github.com/python/mypy/issues/13800. Since it didn't fix any known problems (just some stylistic nits that we had), let's just revert the PR.
This commit is contained in:
Alex Waygood
2023-07-09 16:43:32 +01:00
committed by GitHub
parent aed8c3fe1c
commit 81b8211d0e
12 changed files with 21 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ class Decimal:
def from_float(cls, __f: float) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = None) -> str: ...

View File

@@ -22,6 +22,7 @@ class ReferenceType(Generic[_T]):
__callback__: Callable[[ReferenceType[_T]], Any]
def __new__(cls, __o: _T, __callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
def __call__(self) -> _T | None: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

View File

@@ -86,6 +86,7 @@ class TimerHandle(Handle):
loop: AbstractEventLoop,
context: Context | None = None,
) -> None: ...
def __hash__(self) -> int: ...
def when(self) -> float: ...
def __lt__(self, other: TimerHandle) -> bool: ...
def __le__(self, other: TimerHandle) -> bool: ...

View File

@@ -316,6 +316,7 @@ class int:
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __abs__(self) -> int: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
def __index__(self) -> int: ...
@@ -379,6 +380,7 @@ class float:
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
class complex:
@@ -418,6 +420,7 @@ class complex:
def __neg__(self) -> complex: ...
def __pos__(self) -> complex: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
if sys.version_info >= (3, 11):
def __complex__(self) -> complex: ...
@@ -585,6 +588,7 @@ class str(Sequence[str]):
def __ge__(self, __value: str) -> bool: ...
def __getitem__(self, __key: SupportsIndex | slice) -> str: ...
def __gt__(self, __value: str) -> bool: ...
def __hash__(self) -> int: ...
@overload
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
@overload
@@ -690,6 +694,7 @@ class bytes(Sequence[int]):
def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
def __hash__(self) -> int: ...
@overload
def __getitem__(self, __key: SupportsIndex) -> int: ...
@overload

View File

@@ -35,6 +35,7 @@ class timezone(tzinfo):
def tzname(self, __dt: datetime | None) -> str: ...
def utcoffset(self, __dt: datetime | None) -> timedelta: ...
def dst(self, __dt: datetime | None) -> None: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
UTC: timezone
@@ -106,6 +107,7 @@ class date:
@overload
def __sub__(self, __value: date) -> timedelta: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
if sys.version_info >= (3, 9):
@@ -143,6 +145,7 @@ class time:
def __lt__(self, __value: time) -> bool: ...
def __ge__(self, __value: time) -> bool: ...
def __gt__(self, __value: time) -> bool: ...
def __hash__(self) -> int: ...
def isoformat(self, timespec: str = ...) -> str: ...
@classmethod
def fromisoformat(cls, __time_string: str) -> Self: ...
@@ -217,6 +220,7 @@ class timedelta:
def __ge__(self, __value: timedelta) -> bool: ...
def __gt__(self, __value: timedelta) -> bool: ...
def __bool__(self) -> bool: ...
def __hash__(self) -> int: ...
class datetime(date):
min: ClassVar[datetime]

View File

@@ -85,6 +85,7 @@ class Example:
indent: int = 0,
options: dict[int, bool] | None = None,
) -> None: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
class DocTest:
@@ -103,6 +104,7 @@ class DocTest:
lineno: int | None,
docstring: str | None,
) -> None: ...
def __hash__(self) -> int: ...
def __lt__(self, other: DocTest) -> bool: ...
def __eq__(self, other: object) -> bool: ...
@@ -210,6 +212,7 @@ class DocTestCase(unittest.TestCase):
) -> None: ...
def runTest(self) -> None: ...
def format_failure(self, err: str) -> str: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
class SkipDocTestCase(DocTestCase):

View File

@@ -34,6 +34,7 @@ class _IPAddressBase:
class _BaseAddress(_IPAddressBase, SupportsInt):
def __init__(self, address: object) -> None: ...
def __add__(self, other: int) -> Self: ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __sub__(self, other: int) -> Self: ...
if sys.version_info >= (3, 9):

View File

@@ -39,6 +39,7 @@ class PurePath(PathLike[str]):
@property
def stem(self) -> str: ...
def __new__(cls, *args: StrPath) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __fspath__(self) -> str: ...
def __lt__(self, other: PurePath) -> bool: ...

View File

@@ -102,6 +102,7 @@ if sys.version_info >= (3, 8):
def __init__(self, data: int) -> None: ...
def __index__(self) -> int: ...
def __reduce__(self) -> tuple[type[Self], tuple[int]]: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
class InvalidFileException(ValueError):

View File

@@ -419,6 +419,7 @@ class Row:
def __getitem__(self, __key: int | str) -> Any: ...
@overload
def __getitem__(self, __key: slice) -> tuple[Any, ...]: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __len__(self) -> int: ...
# These return NotImplemented for anything that is not a Row.

View File

@@ -113,6 +113,7 @@ if sys.version_info >= (3, 8):
__radd__ = __add__
def __rsub__(self, x2: float | NormalDist) -> NormalDist: ...
__rmul__ = __mul__
def __hash__(self) -> int: ...
if sys.version_info >= (3, 12):
def correlation(

View File

@@ -921,6 +921,7 @@ class ForwardRef:
def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...