Mypy plugin generates incompatible type overloads for @curry decorated functions with TypeVar
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit dem Reproducer unter Verwendung von TypeVar, @curry, IO und mypy und vergleiche die für _union_sets und _concat_objs generierten Overloads mit den gemeldeten Fehlern. Verfolge den Einstiegspunkt für die Overload-Generierung des Curry-Plugins und füge eine Regression-Prüfung hinzu, die zeigt, dass beide Curry-Funktionen mit den erwarteten Callable-Signaturen typgeprüft werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug report
What's wrong
returns mypy plugin generate incorrect type overloads for curry decorated function with TypeVar arguments
Code to reproduce issue:
from typing import TypeVar
from returns.curry import curry
from returns.io import IO
_T = TypeVar('_T', int, str)
@curry
def _union_sets(first_set: set[_T], second_set: set[_T]) -> set[_T]:
return first_set.union(second_set)
@curry
def _concat_objs(first: _T, second: _T) -> _T:
return first + second
set_1 = IO({1, 2, 3})
set_2 = IO({3, 4, 5})
union = set_1.apply(set_2.apply(IO(_union_sets)))
string_1 = IO('a')
string_2 = IO('b')
concat = string_1.apply(string_2.apply(IO(_concat_objs)))
Mypy gives incompatible type overloaded function error for both curried functions:
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[Set[int]], Callable[..., Set[_T]]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[Set[int]], Callable[[Set[int]], Set[_T]]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[str], Callable[..., _T]]" [arg-type]
error: Argument 1 to "IO" has incompatible type overloaded function; expected "Callable[[str], Callable[[str], _T]]" [arg-type]
How is that should be
Type overloads for functions with TypeVar's should be generated correctly
System information
-
pythonversion: 3.9.7 -
returnsversion: 0.16.0 -
mypyversion: 0.910 -
hypothesisversion (if any): -
pytestversion (if any):
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 156
- Ø Merge
- 3 Std. 44 Min.
- Gemergte PRs (30 T.)
- 22
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus dry-python/returns
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
dry-python/returns#2394 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
dry-python/returns#2365 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
dry-python/returns#2355 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
dry-python/returns#2295 · 4 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
dry-python/returns#2253 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in dry-python/returns
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
KalicoCrew/kalico#1012 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
esphome/esphome.io#7657 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
VNG-Realisatie/gemma-zaken#2658 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
comp/gateway comp/plugins duplicate P3 type/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
NousResearch/hermes-agent#137019 ·
Maintainer antworten meist innerhalb von 1 Tag