python / python/mypy

Daemon does not progate change from decorated to async function

Aperta
#13,706 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-async topic-daemon
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

This fine-grained incremental test case fails (no error on second run):

[case testDecoratedToAsyncReExported]
from mm import f
x: int = f()

[file mm.py]
from m import f

[file m.py]
from d import singleton

@singleton
def f() -> int:
    return 0

[file m.py.2]
async def f() -> str:
    return 'x'

[file d.py]
from typing import Callable

class Singleton:
    def __call__(self) -> int:
        return 0

def singleton(f: Callable[[], int]) -> Singleton: pass
[out]
==
main:2: error: Incompatible types in assignment (expression has type "Coroutine[Any, Any, str]", variable has type "int")

It seems necessary to have a re-export, a decorator, and an async function for this to work. Also changing the return type of the functions seems required. I have no idea so far why this corner case fails.

This fails in 0.971 so it's not a recent regression.

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.

Direzione di ricerca

Riproduci il caso testDecoratedToAsyncReExported nel test harness incrementale a grana fine, usando gli snapshot indicati di mm.py, m.py e d.py. Traccia il motivo per cui la seconda esecuzione non produce alcun errore; il lavoro è completato quando la seconda esecuzione segnala la diagnostica incompatible-types mostrata senza causare regressioni nei test incrementali correlati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.