Spurious error with dynamic keyword arguments
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l'esempio minimo test.py e la definizione collegata datetime.pyi di typeshed, quindi confronta la gestione della chiamata da parte di mypy con --python-version 3.5 e 3.6. L'issue è completata quando la chiamata dinamica con keyword viene accettata per Python 3.6 senza regressioni nel comportamento esistente per 3.5.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100