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:
Jelle Zijlstra
2018-06-11 15:52:44 -07:00
committed by Guido van Rossum
parent ced5d61bb6
commit d2469c0e89
2 changed files with 13 additions and 16 deletions

View File

@@ -153,9 +153,10 @@ def product(iter1: Iterable[Any],
iter4: Iterable[Any],
iter5: Iterable[Any],
iter6: Iterable[Any],
iter7: Iterable[Any], *iterables: Iterable) -> Iterator[Tuple]: ...
iter7: Iterable[Any],
*iterables: Iterable[Any]) -> Iterator[Tuple[Any, ...]]: ...
@overload
def product(*iter: Iterable[_T], repeat: int) -> Iterator[Tuple[_T, ...]]: ...
def product(*iterables: Iterable[Any], repeat: int) -> Iterator[Tuple[Any, ...]]: ...
def permutations(iterable: Iterable[_T],
r: int = ...) -> Iterator[Sequence[_T]]: ...