Skip to content

Commit 1cd8e9f

Browse files
committed
Revert "Remove un-needed __hash__ methods from stdlib (python#8465)"
1 parent aed8c3f commit 1cd8e9f

12 files changed

+21
-0
lines changed

stdlib/_decimal.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Decimal:
7373
def from_float(cls, __f: float) -> Self: ...
7474
def __bool__(self) -> bool: ...
7575
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
76+
def __hash__(self) -> int: ...
7677
def as_tuple(self) -> DecimalTuple: ...
7778
def as_integer_ratio(self) -> tuple[int, int]: ...
7879
def to_eng_string(self, context: Context | None = None) -> str: ...

stdlib/_weakref.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ReferenceType(Generic[_T]):
2222
__callback__: Callable[[ReferenceType[_T]], Any]
2323
def __new__(cls, __o: _T, __callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
2424
def __call__(self) -> _T | None: ...
25+
def __hash__(self) -> int: ...
2526
if sys.version_info >= (3, 9):
2627
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
2728

stdlib/asyncio/events.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class TimerHandle(Handle):
8686
loop: AbstractEventLoop,
8787
context: Context | None = None,
8888
) -> None: ...
89+
def __hash__(self) -> int: ...
8990
def when(self) -> float: ...
9091
def __lt__(self, other: TimerHandle) -> bool: ...
9192
def __le__(self, other: TimerHandle) -> bool: ...

stdlib/builtins.pyi

+5
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ class int:
316316
def __float__(self) -> float: ...
317317
def __int__(self) -> int: ...
318318
def __abs__(self) -> int: ...
319+
def __hash__(self) -> int: ...
319320
def __bool__(self) -> bool: ...
320321
def __index__(self) -> int: ...
321322

@@ -379,6 +380,7 @@ class float:
379380
def __int__(self) -> int: ...
380381
def __float__(self) -> float: ...
381382
def __abs__(self) -> float: ...
383+
def __hash__(self) -> int: ...
382384
def __bool__(self) -> bool: ...
383385

384386
class complex:
@@ -418,6 +420,7 @@ class complex:
418420
def __neg__(self) -> complex: ...
419421
def __pos__(self) -> complex: ...
420422
def __abs__(self) -> float: ...
423+
def __hash__(self) -> int: ...
421424
def __bool__(self) -> bool: ...
422425
if sys.version_info >= (3, 11):
423426
def __complex__(self) -> complex: ...
@@ -585,6 +588,7 @@ class str(Sequence[str]):
585588
def __ge__(self, __value: str) -> bool: ...
586589
def __getitem__(self, __key: SupportsIndex | slice) -> str: ...
587590
def __gt__(self, __value: str) -> bool: ...
591+
def __hash__(self) -> int: ...
588592
@overload
589593
def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
590594
@overload
@@ -690,6 +694,7 @@ class bytes(Sequence[int]):
690694
def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ...
691695
def __len__(self) -> int: ...
692696
def __iter__(self) -> Iterator[int]: ...
697+
def __hash__(self) -> int: ...
693698
@overload
694699
def __getitem__(self, __key: SupportsIndex) -> int: ...
695700
@overload

stdlib/datetime.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class timezone(tzinfo):
3535
def tzname(self, __dt: datetime | None) -> str: ...
3636
def utcoffset(self, __dt: datetime | None) -> timedelta: ...
3737
def dst(self, __dt: datetime | None) -> None: ...
38+
def __hash__(self) -> int: ...
3839

3940
if sys.version_info >= (3, 11):
4041
UTC: timezone
@@ -106,6 +107,7 @@ class date:
106107
@overload
107108
def __sub__(self, __value: date) -> timedelta: ...
108109

110+
def __hash__(self) -> int: ...
109111
def weekday(self) -> int: ...
110112
def isoweekday(self) -> int: ...
111113
if sys.version_info >= (3, 9):
@@ -143,6 +145,7 @@ class time:
143145
def __lt__(self, __value: time) -> bool: ...
144146
def __ge__(self, __value: time) -> bool: ...
145147
def __gt__(self, __value: time) -> bool: ...
148+
def __hash__(self) -> int: ...
146149
def isoformat(self, timespec: str = ...) -> str: ...
147150
@classmethod
148151
def fromisoformat(cls, __time_string: str) -> Self: ...
@@ -217,6 +220,7 @@ class timedelta:
217220
def __ge__(self, __value: timedelta) -> bool: ...
218221
def __gt__(self, __value: timedelta) -> bool: ...
219222
def __bool__(self) -> bool: ...
223+
def __hash__(self) -> int: ...
220224

221225
class datetime(date):
222226
min: ClassVar[datetime]

stdlib/doctest.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Example:
8585
indent: int = 0,
8686
options: dict[int, bool] | None = None,
8787
) -> None: ...
88+
def __hash__(self) -> int: ...
8889
def __eq__(self, other: object) -> bool: ...
8990

9091
class DocTest:
@@ -103,6 +104,7 @@ class DocTest:
103104
lineno: int | None,
104105
docstring: str | None,
105106
) -> None: ...
107+
def __hash__(self) -> int: ...
106108
def __lt__(self, other: DocTest) -> bool: ...
107109
def __eq__(self, other: object) -> bool: ...
108110

@@ -210,6 +212,7 @@ class DocTestCase(unittest.TestCase):
210212
) -> None: ...
211213
def runTest(self) -> None: ...
212214
def format_failure(self, err: str) -> str: ...
215+
def __hash__(self) -> int: ...
213216
def __eq__(self, other: object) -> bool: ...
214217

215218
class SkipDocTestCase(DocTestCase):

stdlib/ipaddress.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class _IPAddressBase:
3434
class _BaseAddress(_IPAddressBase, SupportsInt):
3535
def __init__(self, address: object) -> None: ...
3636
def __add__(self, other: int) -> Self: ...
37+
def __hash__(self) -> int: ...
3738
def __int__(self) -> int: ...
3839
def __sub__(self, other: int) -> Self: ...
3940
if sys.version_info >= (3, 9):

stdlib/pathlib.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class PurePath(PathLike[str]):
3939
@property
4040
def stem(self) -> str: ...
4141
def __new__(cls, *args: StrPath) -> Self: ...
42+
def __hash__(self) -> int: ...
4243
def __eq__(self, other: object) -> bool: ...
4344
def __fspath__(self) -> str: ...
4445
def __lt__(self, other: PurePath) -> bool: ...

stdlib/plistlib.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ if sys.version_info >= (3, 8):
102102
def __init__(self, data: int) -> None: ...
103103
def __index__(self) -> int: ...
104104
def __reduce__(self) -> tuple[type[Self], tuple[int]]: ...
105+
def __hash__(self) -> int: ...
105106
def __eq__(self, other: object) -> bool: ...
106107

107108
class InvalidFileException(ValueError):

stdlib/sqlite3/dbapi2.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ class Row:
419419
def __getitem__(self, __key: int | str) -> Any: ...
420420
@overload
421421
def __getitem__(self, __key: slice) -> tuple[Any, ...]: ...
422+
def __hash__(self) -> int: ...
422423
def __iter__(self) -> Iterator[Any]: ...
423424
def __len__(self) -> int: ...
424425
# These return NotImplemented for anything that is not a Row.

stdlib/statistics.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ if sys.version_info >= (3, 8):
113113
__radd__ = __add__
114114
def __rsub__(self, x2: float | NormalDist) -> NormalDist: ...
115115
__rmul__ = __mul__
116+
def __hash__(self) -> int: ...
116117

117118
if sys.version_info >= (3, 12):
118119
def correlation(

stdlib/typing.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ class ForwardRef:
921921
def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ...
922922

923923
def __eq__(self, other: object) -> bool: ...
924+
def __hash__(self) -> int: ...
924925
if sys.version_info >= (3, 11):
925926
def __or__(self, other: Any) -> _SpecialForm: ...
926927
def __ror__(self, other: Any) -> _SpecialForm: ...

0 commit comments

Comments
 (0)