Unexpected behavior with type narrowing and `Callable`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug Report
I can't really describe the bug well, but hopefully the gist below illustrates it. I'm attempting to go from a list of Callables that includes types (e.g. int, float, etc.) and narrow that to a list of types.
To Reproduce
https://mypy-play.net/?mypy=1.8.0&python=3.11&gist=05a1003c1414446f7196ec4c7c57ded7
Expected Behavior
The gist has no type errors.
Actual Behavior
main.py:5: error: List comprehension has incompatible type List[Callable[..., SupportsComplex]]; expected List[type] [misc]
Found 1 error in 1 file (checked 1 source file)
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.
Direzione di ricerca
Inizia con il gist mypy-play collegato, usando mypy 1.8.0 e Python 3.11, e riproduci l’errore segnalato in main.py:5. Traccia il restringimento del tipo che coinvolge Callable e type, quindi verifica che l’esempio non produca errori di tipo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100