Type field declared in multiple flows as common base
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
The issue names no files, tests, or entry points. Start by reviewing the conditional-assignment examples and the requested common-base inference, then determine the intended typing behavior for optional and related model types. Done means the desired inference is defined and supported without requiring either explicit annotation form.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In this code:
if condition:
s = get_str()
else:
s = get_optional_str()
we currently need to add hints, i.e. (a)
if condition:
s: Optional[str] = get_str()
else:
s = get_optional_str()
or (b)
s: Optional[str]
if condition:
s = get_str()
else:
s = get_optional_str()
Both (a) and (b) seem overly verbose to me, for what seems like a common pattern. If the optionality of s serves a problem for the code that's to follow, that's what mypy should alert us about.
Perhaps optionality is actually somewhat of a special case. A more natural application of this logic would allow for:
if condition:
model = get_foo_model() # FooModel
else:
model = get_bar_model() # BarModel
# model is Model
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Merge medio
- 1g 18h
- PR unite (30g)
- 54
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 python/mypy
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug topic-configuration topic-error-reporting
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
zostera/django-bootstrap4#894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3276 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·