`Union[str, int]` is treated as `dynamic`
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 lo snippet Python fornito con il compilatore statico e analizza come vengono gestite le annotazioni Union[int, str] prima di reveal_type(x). Confronta questo percorso con l’esempio di controllo del flusso mostrato, in cui il tipo locale è Union[str, int]. Il lavoro è completato quando la variabile annotata viene riportata come Union[int, str] invece di dynamic.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What version of Static Python are you using?
6862bbd
2021-10-03
What program did you run?
from typing import Union
x: Union[int, str] = 1
reveal_type(x)
What happened?
The type of x is dynamic
compiler.static.errors.TypedSyntaxError:
reveal_type(x): 'dynamic',
'x' has declared type 'dynamic' and
local type 'Literal[1]'
What should have happened?
We expected the type of x to be Union[int, str] because union types are supported:
x: Any = 1
if True:
x = "hello"
else:
x = 42
reveal_type(x)
# compiler.static.errors.TypedSyntaxError:
# reveal_type(x): 'dynamic',
# 'x' has declared type 'dynamic' and
# local type 'Union[str, int]'
- 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