|
2 | 2 |
|
3 | 3 | # Based on http://docs.python.org/3.2/library/itertools.html
|
4 | 4 |
|
5 |
| -from typing import Iterator, typevar, Iterable, overload, Any, Function, Tuple |
| 5 | +from typing import (Iterator, typevar, Iterable, overload, Any, Function, Tuple, |
| 6 | + Union, Sequence) |
6 | 7 |
|
7 | 8 | T = typevar('T')
|
8 | 9 | S = typevar('S')
|
@@ -41,11 +42,16 @@ def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: pass
|
41 | 42 | def takewhile(predicate: Function[[T], Any],
|
42 | 43 | iterable: Iterable[T]) -> Iterator[T]: pass
|
43 | 44 | def tee(iterable: Iterable[Any], n: int = 2) -> Iterator[Any]: pass
|
44 |
| -def zip_longest(*p: Iterable[Any]) -> Iterator[Any]: pass # TODO fillvalue |
45 |
| - |
46 |
| -def product(*p: Iterable[Any]) -> Iterator[Any]: pass # TODO repeat |
47 |
| -# TODO int with None default |
48 |
| -def permutations(iterable: Iterable[Any], r: int = None) -> Iterator[Any]: pass |
49 |
| -def combinations(iterable: Iterable[Any], r: int) -> Iterable[Any]: pass |
50 |
| -def combinations_with_replacement(iterable: Iterable[Any], |
51 |
| - r: int) -> Iterable[Any]: pass |
| 45 | +def zip_longest(*p: Iterable[Any], |
| 46 | + fillvalue: Any = None) -> Iterator[Any]: pass |
| 47 | + |
| 48 | +# TODO: Return type should be Iterator[Tuple[..]], but unknown tuple shape. |
| 49 | +# Iterator[Sequence[T]] loses this type information. |
| 50 | +def product(*p: Iterable[T], repeat: int = 1) -> Iterator[Sequence[T]]: pass |
| 51 | + |
| 52 | +def permutations(iterable: Iterable[T], |
| 53 | + r: Union[int, None] = None) -> Iterator[Sequence[T]]: pass |
| 54 | +def combinations(iterable: Iterable[T], |
| 55 | + r: int) -> Iterable[Sequence[T]]: pass |
| 56 | +def combinations_with_replacement(iterable: Iterable[T], |
| 57 | + r: int) -> Iterable[Sequence[T]]: pass |
0 commit comments