Way to support attributes for TypedDict
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
Currently i am working with a typeddict that is transforming to AttributeDict and i dont have a way to preserve typings. I am implementing a custom plugin for this but the type is only available for get_type_analyze_hook.
To Reproduce
from typing import TypedDict
Test = TypedDict(
"Test",
{
"from": str,
"test": str
}
)
my_test: Test = {
"from": "lorem",
"test": "11"
}
my_test.test = "22"
Expected Behavior
There wont be any errors.
Actual Behavior
test.py:17: error: "Test" has no attribute "test" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.0.1
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.10.9
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 eseguendo l’esempio TypedDict fornito con mypy 1.0.1 e leggendo il percorso get_type_analyze_hook utilizzato da un plugin personalizzato. Il lavoro è completato quando è stato definito come le chiavi TypedDict trasformate in attributi debbano preservare i propri tipi e l’esempio passi senza l’errore attr-defined.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers, devtools
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100