Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 16 additions & 2 deletions stdlib/@tests/test_cases/builtins/check_tuple.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
from __future__ import annotations

from typing import Tuple
import sys
from typing import Any
from typing_extensions import assert_type


# Empty tuples, see #8275
class TupleSub(Tuple[int, ...]):
class TupleSub(tuple[int, ...]):
pass


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, ...] = tuple(b"spam")
hash(u)
v: tuple[str] = ("",)
hash(v)
w: tuple[()] = ()
hash(w)
hash(tuple(sys.platform))
x: tuple[Any, Any] = ((), ())
hash(x)
4 changes: 2 additions & 2 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from _typeshed import (
SupportsRichComparisonT,
SupportsWrite,
)
from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Set as AbstractSet, Sized
from collections.abc import Awaitable, Callable, Hashable, Iterable, Iterator, MutableSet, 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
Expand Down Expand Up @@ -1163,7 +1163,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, ...]: ...
Expand Down
Loading