python / python/mypy

Error deriving from a composite of two incompatible base classes

オープン
#10,066 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug
主要言語
Python
スター
20.6k
フォーク
3.3k
平均マージ
1日 18時間
マージ済み PR(30日)
54

説明

Simple repro:

class B1:
    def foo(self) -> int:
        ...

class B2:
    def foo(self) -> str:
        ...

class Composite(B1, B2):  # type: ignore
    ...

class AppClass1(Composite):  # <-- no error here
    ...

class AppClass2(Composite, object):  # <-- error here!
    ...

In the real world case, classes B1, B2 and Composite are part of a library (PEP-561-compliant), and classes AppClass1 and AppClass2 are part of the application code that's being type-checked.

The surprising part is that while AppClass2's declaration causes an error (even though AppClass2 didn't introduce the incompatibility), this error isn't seen in AppClass1's declaration.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず issue の最小再現を実行し、AppClass1 と AppClass2 の診断結果を比較します。mypy が Composite からの継承と B1 および B2 にある互換性のない foo の定義をどのように処理するかを追跡します。動作を一貫して理解し、回帰テストでカバーできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。