Skip to content

Add __hash__ stub to classes that are hashable and define __eq__ #10425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class int:
def __abs__(self) -> int: ...
def __bool__(self) -> bool: ...
def __index__(self) -> int: ...
def __hash__(self) -> int: ...

class float:
def __new__(cls, __x: SupportsFloat | SupportsIndex | str | ReadableBuffer = ...) -> Self: ...
Expand Down Expand Up @@ -380,6 +381,7 @@ class float:
def __float__(self) -> float: ...
def __abs__(self) -> float: ...
def __bool__(self) -> bool: ...
def __hash__(self) -> int: ...

class complex:
if sys.version_info >= (3, 8):
Expand Down Expand Up @@ -419,6 +421,7 @@ class complex:
def __pos__(self) -> complex: ...
def __abs__(self) -> float: ...
def __bool__(self) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
def __complex__(self) -> complex: ...

Expand Down Expand Up @@ -606,6 +609,7 @@ class str(Sequence[str]):
@overload
def __rmul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
def __getnewargs__(self) -> tuple[str]: ...
def __hash__(self) -> int: ...

class bytes(Sequence[int]):
@overload
Expand Down Expand Up @@ -710,6 +714,7 @@ class bytes(Sequence[int]):
if sys.version_info >= (3, 11):
def __bytes__(self) -> bytes: ...

def __hash__(self) -> int: ...
def __buffer__(self, __flags: int) -> memoryview: ...

class bytearray(MutableSequence[int]):
Expand Down