mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
fix type for itertools.product (#2129)
Fixes #1850. The fix was already applied to Python 2, but the typevar-based solution there leads to "cannot infer value of type variable" in mypy. I used the following script to check: ```python from itertools import product reveal_type(product([1])) reveal_type(product([1], ['x'], [False], [3.0], [(1,)], [('x',)], [{1}], [{1: 2}], repeat=5)) ```
This commit is contained in:
committed by
Guido van Rossum
parent
ced5d61bb6
commit
d2469c0e89
@@ -60,38 +60,32 @@ _T5 = TypeVar('_T5')
|
||||
_T6 = TypeVar('_T6')
|
||||
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1]]: ...
|
||||
def product(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1],
|
||||
iter2: Iterable[_T2], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1, _T2]]: ...
|
||||
iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1],
|
||||
iter2: Iterable[_T2],
|
||||
iter3: Iterable[_T3], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
|
||||
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1],
|
||||
iter2: Iterable[_T2],
|
||||
iter3: Iterable[_T3],
|
||||
iter4: Iterable[_T4], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ...
|
||||
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1],
|
||||
iter2: Iterable[_T2],
|
||||
iter3: Iterable[_T3],
|
||||
iter4: Iterable[_T4],
|
||||
iter5: Iterable[_T5], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||
iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[_T1],
|
||||
iter2: Iterable[_T2],
|
||||
iter3: Iterable[_T3],
|
||||
iter4: Iterable[_T4],
|
||||
iter5: Iterable[_T5],
|
||||
iter6: Iterable[_T6], *,
|
||||
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
|
||||
iter6: Iterable[_T6]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
|
||||
@overload
|
||||
def product(iter1: Iterable[Any],
|
||||
iter2: Iterable[Any],
|
||||
@@ -99,8 +93,10 @@ def product(iter1: Iterable[Any],
|
||||
iter4: Iterable[Any],
|
||||
iter5: Iterable[Any],
|
||||
iter6: Iterable[Any],
|
||||
iter7: Iterable[Any], *iterables: Iterable,
|
||||
repeat: int = ...) -> Iterator[Tuple]: ...
|
||||
iter7: Iterable[Any],
|
||||
*iterables: Iterable[Any]) -> Iterator[Tuple[Any, ...]]: ...
|
||||
@overload
|
||||
def product(*iterables: Iterable[Any], repeat: int) -> Iterator[Tuple[Any, ...]]: ...
|
||||
|
||||
def permutations(iterable: Iterable[_T],
|
||||
r: Optional[int] = ...) -> Iterator[Tuple[_T, ...]]: ...
|
||||
|
||||
Reference in New Issue
Block a user