Itertools update (#1233)

* Updated the typehints for itertools.

* Removed the overload because it caused problems and cleaned up the imports.

* Update itertools.pyi

Added back optionality of second argument for itertools.permutations.

* Update itertools.pyi

Moved the Optional which I accidentially put on the wrong function -.-
This commit is contained in:
Manuel Krebber
2017-05-03 17:53:48 +02:00
committed by Jelle Zijlstra
parent c96a64d421
commit 2d96eecd30

View File

@@ -3,7 +3,7 @@
# Based on http://docs.python.org/3.2/library/itertools.html
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
Union, Sequence, Generic, Optional)
Generic, Optional)
_T = TypeVar('_T')
_S = TypeVar('_S')
@@ -44,20 +44,18 @@ def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ...
def islice(iterable: Iterable[_T], start: int, stop: Optional[int],
step: int = ...) -> Iterator[_T]: ...
def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ...
def starmap(func: Callable[..., _S], iterable: Iterable[Iterable[Any]]) -> Iterator[_S]: ...
def takewhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def tee(iterable: Iterable[Any], n: int = ...) -> Iterator[Any]: ...
def tee(iterable: Iterable[_T], n: int = ...) -> Tuple[Iterator[_T], ...]: ...
def zip_longest(*p: Iterable[Any],
fillvalue: Any = ...) -> Iterator[Any]: ...
# TODO: Return type should be Iterator[Tuple[..]], but unknown tuple shape.
# Iterator[Sequence[_T]] loses this type information.
def product(*p: Iterable[_T], repeat: int = ...) -> Iterator[Sequence[_T]]: ...
def product(*p: Iterable[_T], repeat: int = ...) -> Iterator[Tuple[_T, ...]]: ...
def permutations(iterable: Iterable[_T],
r: Union[int, None] = ...) -> Iterator[Sequence[_T]]: ...
r: Optional[int] = ...) -> Iterator[Tuple[_T, ...]]: ...
def combinations(iterable: Iterable[_T],
r: int) -> Iterable[Sequence[_T]]: ...
r: int) -> Iterable[Tuple[_T, ...]]: ...
def combinations_with_replacement(iterable: Iterable[_T],
r: int) -> Iterable[Sequence[_T]]: ...
r: int) -> Iterable[Tuple[_T, ...]]: ...