From 25b27efdf7219b80648f76571c9f2cd68542255f Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Mon, 1 Jun 2026 22:35:47 +0800 Subject: [PATCH 1/3] commit 1 --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 096d440ac38c..df1b4dc7091b 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -30,7 +30,7 @@ from _typeshed import ( SupportsRichComparisonT, SupportsWrite, ) -from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized +from collections.abc import Awaitable, Callable, Hashable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType, UnionType @@ -1152,7 +1152,7 @@ class tuple(Sequence[_T_co]): def __gt__(self, value: tuple[_T_co, ...], /) -> bool: ... def __ge__(self, value: tuple[_T_co, ...], /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... - def __hash__(self) -> int: ... + def __hash__(self: tuple[Hashable, ...]) -> int: ... @overload def __add__(self, value: tuple[_T_co, ...], /) -> tuple[_T_co, ...]: ... From 2bd224d58d49744ba21b04384269a0a4b4275f69 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Thu, 16 Jul 2026 21:14:43 +0800 Subject: [PATCH 2/3] tests? --- .../@tests/test_cases/builtins/check_tuple.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/stdlib/@tests/test_cases/builtins/check_tuple.py b/stdlib/@tests/test_cases/builtins/check_tuple.py index bc0d8db28389..2454d7196c77 100644 --- a/stdlib/@tests/test_cases/builtins/check_tuple.py +++ b/stdlib/@tests/test_cases/builtins/check_tuple.py @@ -1,6 +1,8 @@ from __future__ import annotations -from typing import Tuple +import sys +from collections.abc import MutableSequence +from typing import Any, Tuple, TypeVar from typing_extensions import assert_type @@ -11,3 +13,22 @@ class TupleSub(Tuple[int, ...]): assert_type(TupleSub(), TupleSub) assert_type(TupleSub([1, 2, 3]), TupleSub) + +# Hashability shenanigans, see #15852 +t: Tuple[int, int] = (1, 3) +hash(t) +u: Tuple[int, ...] = t +hash(u) +v: Tuple[int] = u +hash(v) +w: Tuple[()] = u +hash(w) +hash(tuple(sys.platform)) +hash(([],)) # type: ignore +x: Tuple[Any, Any] = ({}, ()) +hash(x) +y = (), +assert_type(y, Tuple[Tuple[()]]) +hash(y) +z = ({}, ()) +hash(z) # type: ignore From f6afb86c7e0ef666be8ae0f058e1b4fd8a4c505a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 13:16:46 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/@tests/test_cases/builtins/check_tuple.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/@tests/test_cases/builtins/check_tuple.py b/stdlib/@tests/test_cases/builtins/check_tuple.py index 2454d7196c77..dd73d957874d 100644 --- a/stdlib/@tests/test_cases/builtins/check_tuple.py +++ b/stdlib/@tests/test_cases/builtins/check_tuple.py @@ -24,11 +24,11 @@ class TupleSub(Tuple[int, ...]): w: Tuple[()] = u hash(w) hash(tuple(sys.platform)) -hash(([],)) # type: ignore +hash(([],)) # type: ignore x: Tuple[Any, Any] = ({}, ()) hash(x) -y = (), +y = ((),) assert_type(y, Tuple[Tuple[()]]) hash(y) z = ({}, ()) -hash(z) # type: ignore +hash(z) # type: ignore