better static checks on initializing CheckedDict variables with dictionary literals
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Inizia da cinder/3.8/Lib/test/test_compiler/test_static/tests.py, in particolare da test_compile_checked_dict_with_annotation_wrong_key_type e dal test simile per il tipo di valore errato. Esegui questi test e traccia il comportamento del verificatore statico per un’annotazione CheckedDict a cui viene assegnato un literal di dizionario; il lavoro è completo quando le espressioni delle chiavi vengono verificate rispetto a T1 e i valori rispetto a T2, e la mancata corrispondenza della chiave viene segnalata direttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
a4a71ae
2021-12-20
What program did you run?
from __static__ import CheckedDict
class B: pass
def testfunc():
x: CheckedDict[B, int] = {object():42}
return x
This program is found in cinder/3.8/Lib/test/test_compiler/test_static/tests.py. This test is labeled test_compile_checked_dict_with_annotation_wrong_key_type. There is a similar test labeled test_compile_checked_dict_with_annotation_wrong_value_type.
What happened?
compiler.errors.TypedSyntaxError: type mismatch: Exact[chkdict[object, Literal[42]]] cannot be assigned to Exact[chkdict[__main__.B, int]]
What should have happened?
We expected a compile-time error complaining that object cannot be assigned to B. In general, we expect that everytime the type checker sees x: CheckedDict[T1, T2] = { e1: e2, ... }, it checks every key expression e1 against T1, and every e2 against T2.
- Lingua principale
- Python
- Stelle
- 3.8k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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.
Altre issue di facebookincubator/MetaPython
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
facebookincubator/MetaPython#147 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
facebookincubator/MetaPython#146 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
facebookincubator/MetaPython#145 · 4 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
facebookincubator/MetaPython#144 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
facebookincubator/MetaPython#129 · 2 commenti ·
Tutte le issue di facebookincubator/MetaPython
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·