From f3ac7a404dd89b32189bf42f58ba68fda70eb975 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 2 Aug 2022 11:28:49 +0300 Subject: [PATCH] Remove un-needed `__hash__` methods from `stdlib` --- stdlib/_decimal.pyi | 1 - stdlib/_weakref.pyi | 1 - stdlib/asyncio/events.pyi | 1 - stdlib/builtins.pyi | 5 ----- stdlib/datetime.pyi | 4 ---- stdlib/doctest.pyi | 3 --- stdlib/ipaddress.pyi | 1 - stdlib/pathlib.pyi | 1 - stdlib/plistlib.pyi | 1 - stdlib/sqlite3/dbapi2.pyi | 1 - stdlib/statistics.pyi | 1 - stdlib/typing.pyi | 1 - 12 files changed, 21 deletions(-) diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index 71dff44658be..46ce87718770 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -74,7 +74,6 @@ class Decimal: def from_float(cls: type[Self], __f: float) -> Self: ... def __bool__(self) -> bool: ... def compare(self, other: _Decimal, context: Context | 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 = ...) -> str: ... diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index 329cd0dd6458..742bc3ad9f36 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -23,7 +23,6 @@ class ReferenceType(Generic[_T]): __callback__: Callable[[ReferenceType[_T]], Any] def __new__(cls: type[Self], 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: ... diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 0eeebbc3ab8f..373647a9ddc7 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -85,7 +85,6 @@ class TimerHandle(Handle): loop: AbstractEventLoop, context: Context | None = ..., ) -> None: ... - def __hash__(self) -> int: ... def when(self) -> float: ... def __lt__(self, other: TimerHandle) -> bool: ... def __le__(self, other: TimerHandle) -> bool: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 1a88e708aecd..124a524caeaf 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -296,7 +296,6 @@ 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: ... @@ -360,7 +359,6 @@ class float: def __int__(self) -> int: ... def __float__(self) -> float: ... def __abs__(self) -> float: ... - def __hash__(self) -> int: ... def __bool__(self) -> bool: ... class complex: @@ -388,7 +386,6 @@ 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: ... @@ -550,7 +547,6 @@ class str(Sequence[str]): def __ge__(self, __x: str) -> bool: ... def __getitem__(self, __i: SupportsIndex | slice) -> str: ... def __gt__(self, __x: str) -> bool: ... - def __hash__(self) -> int: ... @overload def __iter__(self: LiteralString) -> Iterator[LiteralString]: ... @overload @@ -660,7 +656,6 @@ class bytes(ByteString): def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... - def __hash__(self) -> int: ... @overload def __getitem__(self, __i: SupportsIndex) -> int: ... @overload diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 4f93eb7205da..780ee941baa5 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -29,7 +29,6 @@ class timezone(tzinfo): min: ClassVar[timezone] max: ClassVar[timezone] def __init__(self, offset: timedelta, name: str = ...) -> None: ... - def __hash__(self) -> int: ... if sys.version_info >= (3, 11): UTC: timezone @@ -94,7 +93,6 @@ class date: @overload def __sub__(self, __other: date) -> timedelta: ... - def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... if sys.version_info >= (3, 9): @@ -132,7 +130,6 @@ class time: def __lt__(self, __other: time) -> bool: ... def __ge__(self, __other: time) -> bool: ... def __gt__(self, __other: time) -> bool: ... - def __hash__(self) -> int: ... def isoformat(self, timespec: str = ...) -> str: ... @classmethod def fromisoformat(cls: type[Self], __time_string: str) -> Self: ... @@ -200,7 +197,6 @@ class timedelta(SupportsAbs[timedelta]): def __ge__(self, __other: timedelta) -> bool: ... def __gt__(self, __other: timedelta) -> bool: ... def __bool__(self) -> bool: ... - def __hash__(self) -> int: ... class datetime(date): min: ClassVar[datetime] diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 6bb1bf9d33c5..382d9578ce80 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -85,7 +85,6 @@ class Example: indent: int = ..., options: dict[int, bool] | None = ..., ) -> None: ... - def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... class DocTest: @@ -104,7 +103,6 @@ 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: ... @@ -211,7 +209,6 @@ class DocTestCase(unittest.TestCase): def format_failure(self, err: str) -> str: ... def debug(self) -> None: ... def id(self) -> str: ... - def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... def shortDescription(self) -> str: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 4f9109363b53..d324f52ac25a 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -31,7 +31,6 @@ class _IPAddressBase: class _BaseAddress(_IPAddressBase, SupportsInt): def __init__(self, address: object) -> None: ... def __add__(self: Self, other: int) -> Self: ... - def __hash__(self) -> int: ... def __int__(self) -> int: ... def __sub__(self: Self, other: int) -> Self: ... def __format__(self, fmt: str) -> str: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 05ad3c55086b..2a0f1760cae5 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -38,7 +38,6 @@ class PurePath(PathLike[str]): @property def stem(self) -> str: ... def __new__(cls: type[Self], *args: StrPath) -> Self: ... - def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... def __fspath__(self) -> str: ... def __lt__(self, other: PurePath) -> bool: ... diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 89acc5b53851..9dcfcdb126cb 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -99,7 +99,6 @@ if sys.version_info >= (3, 8): def __init__(self, data: int) -> None: ... def __index__(self) -> int: ... def __reduce__(self: Self) -> tuple[type[Self], tuple[int]]: ... - def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... class InvalidFileException(ValueError): diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 01c4c226ecb7..83d2df1e6da9 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -420,7 +420,6 @@ class Row: def __getitem__(self, __index: int | str) -> Any: ... @overload def __getitem__(self, __index: 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. diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 58e7fd909f1f..a01665ad8227 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -113,7 +113,6 @@ 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, 10): def correlation(__x: Sequence[_Number], __y: Sequence[_Number]) -> float: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 2bb840b643a5..cda01e53a6e5 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -813,7 +813,6 @@ 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: ...