Type async function result as CoroutineType instead of Coroutine

Aperta
#5,611 0 commenti 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
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, rust

Direzione di ricerca

Start by reading Pyrefly’s handling of async function return types and how it models coroutine objects; the issue provides a minimal reproduction in its body. Compare the inferred result with the expected CoroutineType[Any, Any, int] assignment and check whether the behavior matches Pyright. Done means the example type-checks without the reported bad-assignment error.

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

Descrizione

Describe the Bug
async def f() -> int:
   return 1

c: CoroutineType[Any, Any, int] = f()

gives:

 ERROR `Coroutine[Unknown, Unknown, int]` is not assignable to `CoroutineType[Any, Any, int]` [bad-assignment]

I'd expect this assignment to be accepted as calling an async def function produces an object whose runtime type is exactly CoroutineType. Pyright accepts this example. Could Pyrefly infer the more specific type in this case?

Sandbox Link

Sandbox

(Only applicable for extension issues) IDE Information

No response

Lingua principale
Rust
Stelle
7.2k
Fork
578
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 facebook/pyrefly

Tutte le issue di facebook/pyrefly

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.