Passing `**dict(...)` to `functools.partial` confuses mypy
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
Something like partial(func, **dict(a=1)) confuses mypy which seems to expect the dictionary keys to contain all the arguments to func, leading to errors if positional arguments are not specified (see this playground / gist), or if only a few arguments are specified and later more as passed to partial's return value (see this playground / gist).
Expected Behavior
I realise that mypy cannot know what ends up in an untyped dictionary, but it should maybe just give up in this case.
Actual Behavior
See gist.
Your Environment
- Mypy version used:
mypy 1.15.0 (compiled: yes), but alsomasterwhile using the playground - Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.10.1, but also 3.13 while using the playground
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 riproducendo i due esempi nei mypy playgrounds e gists collegati con mypy 1.15.0 e master. Traccia il modo in cui functools.partial gestisce i dizionari spacchettati, quindi verifica che i casi segnalati non producano più diagnostica errata, mentre le chiamate valide a partial continuino a essere controllate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100