Skip to content

Restrict types for stubs in itertools #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions stubs/3.2/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# Based on http://docs.python.org/3.2/library/itertools.html

from typing import Iterator, typevar, Iterable, overload, Any, Function, Tuple
from typing import (Iterator, typevar, Iterable, overload, Any, Function, Tuple,
Union, Sequence)

T = typevar('T')
S = typevar('S')
Expand Down Expand Up @@ -41,11 +42,16 @@ def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: pass
def takewhile(predicate: Function[[T], Any],
iterable: Iterable[T]) -> Iterator[T]: pass
def tee(iterable: Iterable[Any], n: int = 2) -> Iterator[Any]: pass
def zip_longest(*p: Iterable[Any]) -> Iterator[Any]: pass # TODO fillvalue

def product(*p: Iterable[Any]) -> Iterator[Any]: pass # TODO repeat
# TODO int with None default
def permutations(iterable: Iterable[Any], r: int = None) -> Iterator[Any]: pass
def combinations(iterable: Iterable[Any], r: int) -> Iterable[Any]: pass
def combinations_with_replacement(iterable: Iterable[Any],
r: int) -> Iterable[Any]: pass
def zip_longest(*p: Iterable[Any],
fillvalue: Any = None) -> Iterator[Any]: pass

# 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 = 1) -> Iterator[Sequence[T]]: pass

def permutations(iterable: Iterable[T],
r: Union[int, None] = None) -> Iterator[Sequence[T]]: pass
def combinations(iterable: Iterable[T],
r: int) -> Iterable[Sequence[T]]: pass
def combinations_with_replacement(iterable: Iterable[T],
r: int) -> Iterable[Sequence[T]]: pass