Revert "add overload to tuple.__new__ to better express an empty tuple" (#8278)

This reverts commit 64554bdd5d.

Also add a test case.
This commit is contained in:
Jelle Zijlstra
2022-07-12 12:29:37 -07:00
committed by GitHub
parent 2a1b33df9f
commit 2a7439e106
2 changed files with 12 additions and 6 deletions

View File

@@ -904,12 +904,7 @@ class slice:
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
# overloads are ordered this way to pass `isinstance` checks
# see: https://github.com/python/typeshed/pull/7454#issuecomment-1061490888
@overload
def __new__(cls: type[Self], __iterable: Iterable[_T_co]) -> Self: ...
@overload
def __new__(cls) -> tuple[()]: ...
def __new__(cls: type[Self], __iterable: Iterable[_T_co] = ...) -> Self: ...
def __len__(self) -> int: ...
def __contains__(self, __x: object) -> bool: ...
@overload

View File

@@ -0,0 +1,11 @@
from typing_extensions import assert_type
from typing import Tuple
# Empty tuples, see #8275
class TupleSub(Tuple[int, ...]):
pass
assert_type(TupleSub(), TupleSub)
assert_type(TupleSub([1, 2, 3]), TupleSub)