dict(zip()) and itertools.product

Abierto
#3,884 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
devtools

Línea de trabajo

Reproduce the reported error with Python 3.6.1 and mypy 0.521 using the two dict(zip()) examples in the issue. Trace how zip() and itertools.product(..., repeat=2) are typed; done means the second example is accepted without weakening the incorrect-type check, with a regression test for this case.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

feature priority-2-low topic-plugins

I think I've noticed a tiny bug.
Python 3.6.1
mypy 0.521

from typing import Tuple, Dict
from itertools import product

# works fine
XY_1: Dict[str, Tuple[int, int]] = dict(zip('abcd', product(range(2), range(2))))
# {'a': (0, 0), 'b': (0, 1), 'c': (1, 0), 'd': (1, 1)}

# error for this one
XY_2: Dict[str, Tuple[int, int]] = dict(zip('abcd', product(range(2), repeat=2)))
# {'a': (0, 0), 'b': (0, 1), 'c': (1, 0), 'd': (1, 1)}

The dictionaries are the same.
Error output:

mypy_test.py:10: error: Argument 2 to "zip" has incompatible type Iterator[Tuple[int]]; expected Iterable[Tuple[int, int]]

I think that this is not essential. So, just in case.
Thanks for the great product!

Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Merge medio
1 d 18 h
PR fusionados (30 d)
54

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python/mypy

Todos los issues de python/mypy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.