Inconsistent "cannot instantiate abstract class" with list of concete types deriving from an abstract base
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
mypy gives inconsistent errors with regard to instantiating classes that derive from a common abstract base class when the derived classes are accessed via a list.
The errors depend on size of the list, and whether the type of the list is inferred or explicit.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=0fb05ed25d3fd593772c6a7586f92929
Expected Behavior
Each example with the same inferred/explicit typing should give the same errors.
Actual Behavior
The example with a list of three elements and inferred type gives an error where all other examples don't
Your Environment
- Mypy version used: 1.4.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている mypy-play の再現を mypy 1.4.1 で開始し、推論された型のリストと明示的に型付けされたリストを比較します。特に3要素の場合を確認してください。これらの例に関係する抽象クラスのインスタンス化チェックを追跡します。同等の推論型付けと明示的な型付けで一貫したエラーが発生すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100