list of types with multiple bases only uses first shared base?
オープン
まだ誰も着手していません。
feature
needs discussion
priority-2-low
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mypytest.py の再現コードから始め、mypy で実行して推論された型とエラーを確認します。複数の共通基底クラスを持つクラスのリストの型がどのように推論されるかを追跡し、その後、複数の基底クラスの関係を失うことなく b1 と b2 の両方が受け入れられることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100