From 25b27efdf7219b80648f76571c9f2cd68542255f Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Mon, 1 Jun 2026 22:35:47 +0800 Subject: [PATCH 1/6] 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/6] 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/6] [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 From 134d9bda450a4f37029683a479a097aabddd3131 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Fri, 17 Jul 2026 15:44:32 +0800 Subject: [PATCH 4/6] bruh --- stdlib/@tests/test_cases/builtins/check_tuple.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/stdlib/@tests/test_cases/builtins/check_tuple.py b/stdlib/@tests/test_cases/builtins/check_tuple.py index dd73d957874d..bc87640c7897 100644 --- a/stdlib/@tests/test_cases/builtins/check_tuple.py +++ b/stdlib/@tests/test_cases/builtins/check_tuple.py @@ -1,8 +1,7 @@ from __future__ import annotations import sys -from collections.abc import MutableSequence -from typing import Any, Tuple, TypeVar +from typing import Any, Tuple, Dict from typing_extensions import assert_type @@ -17,18 +16,15 @@ class TupleSub(Tuple[int, ...]): # Hashability shenanigans, see #15852 t: Tuple[int, int] = (1, 3) hash(t) -u: Tuple[int, ...] = t +u: Tuple[bytes, ...] = tuple(b'spam') hash(u) -v: Tuple[int] = u +v: Tuple[str] = ('',) hash(v) -w: Tuple[()] = u +w: Tuple[()] = () hash(w) hash(tuple(sys.platform)) hash(([],)) # type: ignore -x: Tuple[Any, Any] = ({}, ()) +x: Tuple[Any, Any] = ((), ()) hash(x) -y = ((),) -assert_type(y, Tuple[Tuple[()]]) -hash(y) -z = ({}, ()) +z: Tuple[Tuple[Any, ...], Dict[str, Any]] = ((), {}) hash(z) # type: ignore From bd3ccfa244f5a6d242b3c7f54f9575d799f2262b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 07:46:47 +0000 Subject: [PATCH 5/6] [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 bc87640c7897..319ca837ef8e 100644 --- a/stdlib/@tests/test_cases/builtins/check_tuple.py +++ b/stdlib/@tests/test_cases/builtins/check_tuple.py @@ -1,7 +1,7 @@ from __future__ import annotations import sys -from typing import Any, Tuple, Dict +from typing import Any, Dict, Tuple from typing_extensions import assert_type @@ -16,9 +16,9 @@ class TupleSub(Tuple[int, ...]): # Hashability shenanigans, see #15852 t: Tuple[int, int] = (1, 3) hash(t) -u: Tuple[bytes, ...] = tuple(b'spam') +u: Tuple[bytes, ...] = tuple(b"spam") hash(u) -v: Tuple[str] = ('',) +v: Tuple[str] = ("",) hash(v) w: Tuple[()] = () hash(w) From 4fe91470127a3248267832a3c551e0fb755ff44c Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Fri, 17 Jul 2026 16:15:43 +0800 Subject: [PATCH 6/6] Hotfix --- stdlib/@tests/test_cases/builtins/check_tuple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/@tests/test_cases/builtins/check_tuple.py b/stdlib/@tests/test_cases/builtins/check_tuple.py index 319ca837ef8e..5c1f2e7ca8d5 100644 --- a/stdlib/@tests/test_cases/builtins/check_tuple.py +++ b/stdlib/@tests/test_cases/builtins/check_tuple.py @@ -16,7 +16,7 @@ class TupleSub(Tuple[int, ...]): # Hashability shenanigans, see #15852 t: Tuple[int, int] = (1, 3) hash(t) -u: Tuple[bytes, ...] = tuple(b"spam") +u: Tuple[int, ...] = tuple(b"spam") hash(u) v: Tuple[str] = ("",) hash(v)