list of types with multiple bases only uses first shared base?
Aperta
Nessuno ha ancora preso questa issue.
feature
needs discussion
priority-2-low
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
i may be misunderstanding something, but it seems that when making a list of types, each with multiple shared base classes, mypy mistakenly infers this to be a list of the first base only, missing others
$ cat mypytest.py
# two different base classes with different attributes
class B1:
b1 = None
class B2:
b2 = None
# two classes that subclass both B1 and B2
class S1(B1, B2):
pass
class S2(B1, B2):
pass
# a list of the subclasses
types = [S1, S2]
# it seems mypy thinks `types` is List[Type[B1]]
ok = [x.b1 for x in types]
why_not_ok = [x.b2 for x in types]
$ mypy mypytest.py
mypytest.py:24: error: "Type[B1]" has no attribute "b2"
$ mypy --version
mypy 0.770+dev.b2edab25b7e4a6131484bb6edf314e2fa078aee7
$ python -V
Python 3.7.3
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.
Direzione di ricerca
Inizia con la riproduzione in mypytest.py ed eseguila con mypy per confermare il tipo inferito e l’errore. Traccia il modo in cui viene inferito il tipo di un elenco di classi con più classi base condivise, quindi verifica che sia b1 sia b2 vengano accettati senza perdere la relazione tra le classi base multiple.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100