add overload to tuple.__new__ to better express an empty tuple (#7454)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
David Brownman
2022-07-05 17:28:08 -07:00
committed by GitHub
parent 043d9dac61
commit 64554bdd5d

View File

@@ -910,7 +910,12 @@ class slice:
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
def __new__(cls: type[Self], __iterable: Iterable[_T_co] = ...) -> Self: ...
# 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 __len__(self) -> int: ...
def __contains__(self, __x: object) -> bool: ...
@overload