Passing `**dict(...)` to `functools.partial` confuses mypy
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die beiden Beispiele in den verlinkten mypy-Playgrounds und Gists mit mypy 1.15.0 und master zu reproduzieren. Verfolge, wie functools.partial entpackte Dictionaries verarbeitet, und überprüfe anschließend, dass die gemeldeten Fälle keine fehlerhaften Diagnosen mehr erzeugen, während gültige Aufrufe von partial weiterhin geprüft werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100