Spurious error with dynamic keyword arguments
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug Report
The expression datetime.timedelta(**{"seconds": 1.0}) works correctly in python, but mypy reports it as an error if the python-version parameter is 3.6 or greater. (note that the typeshed definition of timedelta.__init__ is conditioned on the python version, which explains why that parameter has this effect)
To Reproduce
test.py:
import datetime
datetime.timedelta(**{"seconds": 1.0})
Run mypy --python-version 3.5 test.py and mypy --python-version 3.6 test.py
Actual Behavior
With --python-version 3.5, there are no errors. With --python-version 3.6, it reports:
test.py:3: error: Argument 1 to "timedelta" has incompatible type "**Dict[str, float]"; expected "int"
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: tested both 0.740 and 0.790
- Mypy command-line flags:
--python-version - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.8
- Operating system and version: linux
Minimal test case: https://repl.it/@bdarnell/mypy-dynamic-keyword-args-bug-report
CI build in which this was initially discovered: https://travis-ci.org/github/tornadoweb/tornado/jobs/740396440
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el ejemplo mínimo de test.py y la definición vinculada de typeshed datetime.pyi; después, compara cómo mypy gestiona la llamada con --python-version 3.5 y 3.6. El issue estará terminado cuando la llamada dinámica con palabras clave se acepte para Python 3.6 sin hacer que el comportamiento existente de 3.5 deje de funcionar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100