Document how joins work

Aperta
#5,219 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
documentation

Direzione di ricerca

Start by locating the mypy documentation covering type inference for collections and related typing behavior. Use the A, B, and C example from the issue to verify how inferred common base classes differ from an explicitly annotated Union. Done means the behavior is explained with accessible examples without relying heavily on the term “join”.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation priority-1-normal topic-join-v-union

Joins tend to produce common base classes instead of unions, and this may be surprising. I don't think that this is documented, at least not very clearly. The discussion probably shouldn't rely heavily on the relatively obscure term "join" (especially as the operation technically isn't quite a lattice join) -- rather we can use examples and more informal explanations.

Typical example where this is relevant:

class A: pass
class B(A): pass
class C(A): pass

x = [B(), C()]  # Inferrred type List[A], not List[Union[B, C]]
y: List[Union[B, C]]
y = [B(), C()]  # Now the type is List[Union[B, C]]
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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.