Mypy plugin generates incompatible type overloads for @curry decorated functions with TypeVar
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con il riproduttore che usa TypeVar, @curry, IO e mypy, quindi confronta gli overload generati per _union_sets e _concat_objs con gli errori segnalati. Traccia il punto di ingresso della generazione degli overload del plugin curry e aggiungi un controllo di regressione che mostri che entrambe le funzioni curry superano il controllo dei tipi con le firme Callable previste.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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):
- Lingua principale
- Python
- Stelle
- 4.4k
- Fork
- 154
- Merge medio
- 3h 5m
- PR unite (30g)
- 22
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.
Altre issue di dry-python/returns
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
dry-python/returns#2394 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
dry-python/returns#2365 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
dry-python/returns#2355 · 1 commento ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
dry-python/returns#2295 · 4 commenti · 1 reazione ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
dry-python/returns#2253 · 2 commenti ·
Tutte le issue di dry-python/returns
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·