Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Mypy plugin generates incompatible type overloads for @curry decorated functions with TypeVar

Aperta
#1,071 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

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

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

  • python version: 3.9.7

  • returns version: 0.16.0

  • mypy version: 0.910

  • hypothesis version (if any):

  • pytest version (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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dry-python/returns

Tutte le issue di dry-python/returns

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.