From e58db9d649c276cb3097c706e8625e4a4ae3ce3d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 3 Feb 2022 07:56:09 -0800 Subject: [PATCH] zip.__iter__ and reversed.__iter__ return self (On 3.9) ``` >>> class X(reversed): pass ... >>> x = X("abc") >>> type(x) >>> type(iter(x)) >>> class Y(zip): ... pass ... >>> y = Y("abc", "def") >>> type(y) >>> type(iter(y)) ``` --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 3aa74fa53b80..e568ce6a7be2 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1412,7 +1412,7 @@ class reversed(Iterator[_T], Generic[_T]): def __init__(self, __sequence: Reversible[_T]) -> None: ... @overload def __init__(self, __sequence: SupportsLenAndGetItem[_T]) -> None: ... - def __iter__(self) -> Iterator[_T]: ... + def __iter__(self: Self) -> Self: ... def __next__(self) -> _T: ... def repr(__obj: object) -> str: ... @@ -1524,7 +1524,7 @@ class zip(Iterator[_T_co], Generic[_T_co]): *iterables: Iterable[Any], ) -> zip[tuple[Any, ...]]: ... - def __iter__(self) -> Iterator[_T_co]: ... + def __iter__(self: Self) -> Self: ... def __next__(self) -> _T_co: ... # Signature of `builtins.__import__` should be kept identical to `importlib.__import__`