Confusing error message: List item 0 has incompatible type "Type[Linear]"; expected "Type[Linear]"
オープン
まだ誰も着手していません。
bug
false-positive
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
In some situations, mypy can report that there was an incompatible type X, but then say that the expected type was also X. Regardless of whether or not the program is correct or not, this error message is bad.
To Reproduce
from typing import Any
class Linear:
def __init__(self, **kwargs) -> None:
pass
class QatLinear(Linear):
def __init__(self, qconfig=None):
pass
def f(x: Any):
if type(x) in [Linear, QatLinear]:
pass
Expected Behavior mypy gives me a good error message
Actual Behavior
(base) ezyang-mbp:~ ezyang$ mypy t.py
t.py:12: error: List item 0 has incompatible type "Type[Linear]"; expected "Type[Linear]"
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: mypy 0.780
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: Python 3.7
- Operating system and version: OS X
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告された mypy バージョンまたは現在の checkout で、提供された Python 再現プログラムを実行し、次に、リスト項目の非互換性に関する診断をフォーマットする型チェッカーの経路を追跡します。再現したケースで、表示上同一の型が非互換として報告されなくなり、その診断に対するリグレッションカバレッジが追加されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100