Skip to content

Commit

Permalink
Provide more precise type hints for itertools.permutations (python#11019
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Serious-senpai authored Nov 11, 2023
1 parent 571cc6d commit 6764465
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions stdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,19 @@ class product(Iterator[_T_co]):
def __iter__(self) -> Self: ...
def __next__(self) -> _T_co: ...

class permutations(Iterator[tuple[_T, ...]], Generic[_T]):
def __init__(self, iterable: Iterable[_T], r: int | None = ...) -> None: ...
class permutations(Iterator[_T_co]):
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[3]) -> permutations[tuple[_T, _T, _T]]: ...
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[4]) -> permutations[tuple[_T, _T, _T, _T]]: ...
@overload
def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> permutations[tuple[_T, _T, _T, _T, _T]]: ...
@overload
def __new__(cls, iterable: Iterable[_T], r: int | None = ...) -> permutations[tuple[_T, ...]]: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[_T, ...]: ...
def __next__(self) -> _T_co: ...

class combinations(Iterator[_T_co]):
@overload
Expand Down

0 comments on commit 6764465

Please sign in to comment.