Resolution of disallowed `Type[Type[T]]` and casting to a blank `Type`
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
(A clear and concise description of what the bug is.)
Mypy is inferring types that are illegal to create or annotate, like Type[Type[T]], which causes errors during linting checks.
The only ways to resolve it are either # type: ignore, which seems counter-intuitive when writing type safe code, or doing a typing.cast(typing.Type) which defeats the purpose of the generic typehint
To Reproduce
Playground link
Expected Behavior
I'd expect Type[Type[T]] to coalesce into the legal generic Type[T]
Actual Behavior
Mypy sees the expected type as Type[Type[T]], causing an error when not casting or ignoring.
Your Environment
- Mypy version used: 0.991 (compiled: yes)
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): setup.cfg from project this was first noticed in - Python version used: 3.10
The template asks for a link to the affected repository, if it's open source. This can be found in the EnforceTypes repo
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 la riproduzione collegata di mypy-play usando Python 3.10 e mypy 0.991, quindi segui come vengono analizzate le espressioni Type annidate. L’issue non indica alcun file sorgente o test di mypy; il lavoro è completato quando l’esempio accetta la relazione Type[T] prevista senza richiedere type: ignore o un typing.cast vuoto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100