questions about CheckedDict and unknown types
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia riproducendo i due esempi nell’issue con il commit di static Python indicato e confronta il comportamento previsto descritto nell’issue 59. Traccia la gestione dei tipi generici sconosciuti per le annotazioni e delle chiamate al costruttore di CheckedDict. Il lavoro è completato quando entrambe le forme sono accettate e il risultato del costruttore è compatibile con CheckedDict[str, object].
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
IIUC (based on issue 59), types like CheckedDict[str, Set[str]] where SP doesn't understand part of the type should:
- be allowed, and
- turn into
CheckedDict[str, object]
But neither seems to work. (I'm running SP commit 1b01cd886.)
First, this type doesn't work except in a constructor call. Other type annotations give an error:
from __static__ import CheckedDict
from typing import Set
def f(dd: CheckedDict[int, Set[str]]):
return
# def f(dd: CheckedDict[int, Set[str]]):
# TypeError: expected type or Optional[T] for generic argument
Second, the constructor call gives a chkdict[str, dynamic] instead of replacing the unknown type with object:
from __static__ import CheckedDict
from typing import Set
d0: CheckedDict[str, dynamic] = CheckedDict[str, Set[str]]({})
# OK
d1: CheckedDict[str, object] = CheckedDict[str, Set[str]]({})
# compiler.errors.TypedSyntaxError: type mismatch: chkdict[str, dynamic] cannot be assigned to chkdict[str, object]
Are these problems?
- 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
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
simonw/sqlite-utils#872 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100