Mypy doesn't assign TypedDict output as Literals
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
(A clear and concise description of what the bug is.)
To Reproduce
When I do this, I get an error saying a literal is required. When I add a literal it can't assign a string to a literal.
Actual Behavior
When using the first way, I got this error:
main.py:19: error: TypedDict key must be a string literal; expected one of ("b", "c", "d") [literal-required]
Found 1 error in 1 file (checked 1 source file)
The second way this one:
main.py:19: error: Incompatible types in assignment (expression has type "str", variable has type "Literal['b', 'c', 'd']") [assignment]
Found 1 error in 1 file (checked 1 source file)
Your Environment
I used the standard strict configuration from vscode, I don't know where I could find the version info and default command-line flags.
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 le due riproduzioni mypy-play collegate e confronta il loro comportamento di TypedDict e Literal con la configurazione Python 3.11/latest indicata. Il lavoro è completato quando entrambi gli esempi superano il controllo dei tipi come previsto, senza gli errori segnalati «literal-required» o «incompatible-assignment».
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
- 45/100