`partial` plugin does not handle overloads
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
it appears the new partial plugin added in mypy 1.11 doesn't properly handle overloads (and just picks the first one)
To Reproduce
import functools
from typing import assert_type, overload
@overload
def identity(x: int, *, p: str) -> int: ...
@overload
def identity(x: str, *, p: str) -> str: ...
def identity(x: int | str, *, p: str) -> int | str: return x
p = functools.partial(identity, p='hi')
assert_type(p(1), int)
assert_type(p('hi'), str)
Expected Behavior
(no errors)
Actual Behavior
$ mypy t.py
t.py:13: error: Expression is of type "int", not "str" [assert-type]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.11.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.2
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
Reproduziere das Problem mit dem bereitgestellten functools.partial-, overload- und assert_type-Beispiel, indem du mypy t.py ausführst. Verfolge die Verarbeitung überladener Callables durch das partial-Plugin und füge Abdeckung für sowohl int- als auch str-Argumente hinzu. Als abgeschlossen gilt die Aufgabe, wenn das Beispiel keine Fehler meldet und beide abgeleiteten Rückgabetypen beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100