1"""Stubs for more_itertools.recipes""" 2from typing import ( 3 Any, 4 Callable, 5 Iterable, 6 Iterator, 7 List, 8 Optional, 9 Tuple, 10 TypeVar, 11 Union, 12) 13from typing_extensions import overload, Type 14 15# Type and type variable definitions 16_T = TypeVar('_T') 17_U = TypeVar('_U') 18 19def take(n: int, iterable: Iterable[_T]) -> List[_T]: ... 20def tabulate( 21 function: Callable[[int], _T], start: int = ... 22) -> Iterator[_T]: ... 23def tail(n: int, iterable: Iterable[_T]) -> Iterator[_T]: ... 24def consume(iterator: Iterable[object], n: Optional[int] = ...) -> None: ... 25@overload 26def nth(iterable: Iterable[_T], n: int) -> Optional[_T]: ... 27@overload 28def nth(iterable: Iterable[_T], n: int, default: _U) -> Union[_T, _U]: ... 29def all_equal(iterable: Iterable[object]) -> bool: ... 30def quantify( 31 iterable: Iterable[_T], pred: Callable[[_T], bool] = ... 32) -> int: ... 33def pad_none(iterable: Iterable[_T]) -> Iterator[Optional[_T]]: ... 34def padnone(iterable: Iterable[_T]) -> Iterator[Optional[_T]]: ... 35def ncycles(iterable: Iterable[_T], n: int) -> Iterator[_T]: ... 36def dotproduct(vec1: Iterable[object], vec2: Iterable[object]) -> object: ... 37def flatten(listOfLists: Iterable[Iterable[_T]]) -> Iterator[_T]: ... 38def repeatfunc( 39 func: Callable[..., _U], times: Optional[int] = ..., *args: Any 40) -> Iterator[_U]: ... 41def pairwise(iterable: Iterable[_T]) -> Iterator[Tuple[_T, _T]]: ... 42@overload 43def grouper( 44 iterable: Iterable[_T], n: int 45) -> Iterator[Tuple[Optional[_T], ...]]: ... 46@overload 47def grouper( 48 iterable: Iterable[_T], n: int, fillvalue: _U 49) -> Iterator[Tuple[Union[_T, _U], ...]]: ... 50@overload 51def grouper( # Deprecated interface 52 iterable: int, n: Iterable[_T] 53) -> Iterator[Tuple[Optional[_T], ...]]: ... 54@overload 55def grouper( # Deprecated interface 56 iterable: int, n: Iterable[_T], fillvalue: _U 57) -> Iterator[Tuple[Union[_T, _U], ...]]: ... 58def roundrobin(*iterables: Iterable[_T]) -> Iterator[_T]: ... 59def partition( 60 pred: Optional[Callable[[_T], object]], iterable: Iterable[_T] 61) -> Tuple[Iterator[_T], Iterator[_T]]: ... 62def powerset(iterable: Iterable[_T]) -> Iterator[Tuple[_T, ...]]: ... 63def unique_everseen( 64 iterable: Iterable[_T], key: Optional[Callable[[_T], _U]] = ... 65) -> Iterator[_T]: ... 66def unique_justseen( 67 iterable: Iterable[_T], key: Optional[Callable[[_T], object]] = ... 68) -> Iterator[_T]: ... 69@overload 70def iter_except( 71 func: Callable[[], _T], 72 exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], 73 first: None = ..., 74) -> Iterator[_T]: ... 75@overload 76def iter_except( 77 func: Callable[[], _T], 78 exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], 79 first: Callable[[], _U], 80) -> Iterator[Union[_T, _U]]: ... 81@overload 82def first_true( 83 iterable: Iterable[_T], *, pred: Optional[Callable[[_T], object]] = ... 84) -> Optional[_T]: ... 85@overload 86def first_true( 87 iterable: Iterable[_T], 88 default: _U, 89 pred: Optional[Callable[[_T], object]] = ..., 90) -> Union[_T, _U]: ... 91def random_product( 92 *args: Iterable[_T], repeat: int = ... 93) -> Tuple[_T, ...]: ... 94def random_permutation( 95 iterable: Iterable[_T], r: Optional[int] = ... 96) -> Tuple[_T, ...]: ... 97def random_combination(iterable: Iterable[_T], r: int) -> Tuple[_T, ...]: ... 98def random_combination_with_replacement( 99 iterable: Iterable[_T], r: int 100) -> Tuple[_T, ...]: ... 101def nth_combination( 102 iterable: Iterable[_T], r: int, index: int 103) -> Tuple[_T, ...]: ... 104def prepend(value: _T, iterator: Iterable[_U]) -> Iterator[Union[_T, _U]]: ... 105def convolve(signal: Iterable[_T], kernel: Iterable[_T]) -> Iterator[_T]: ... 106def before_and_after( 107 predicate: Callable[[_T], bool], it: Iterable[_T] 108) -> Tuple[Iterator[_T], Iterator[_T]]: ... 109def triplewise(iterable: Iterable[_T]) -> Iterator[Tuple[_T, _T, _T]]: ... 110def sliding_window( 111 iterable: Iterable[_T], n: int 112) -> Iterator[Tuple[_T, ...]]: ... 113