Skip to content

Commit 824e94a

Browse files
wbolstersrittau
authored andcommitted
Make 2-arg iter() retrun type match passed callable's return type (#3326)
This is a continuation of #3291, which was the initial fix for #3201. The 2-arg version of iter() turns a callable into an iterator. The changes made in #3291 introduce an Any return type for both the callable's return type and the iterator's type, while in reality the return type of the function is always the same as the iterator's type.
1 parent 3ee8fc2 commit 824e94a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

stdlib/2/__builtin__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
11931193
@overload
11941194
def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ...
11951195
@overload
1196-
def iter(__function: Callable[[], Any], __sentinel: Any) -> Iterator[Any]: ...
1196+
def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
11971197
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
11981198
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
11991199
def len(__o: Sized) -> int: ...

stdlib/2and3/builtins.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
11931193
@overload
11941194
def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ...
11951195
@overload
1196-
def iter(__function: Callable[[], Any], __sentinel: Any) -> Iterator[Any]: ...
1196+
def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
11971197
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
11981198
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
11991199
def len(__o: Sized) -> int: ...

0 commit comments

Comments
 (0)