Confusing error: incompatible type "Type[bytes]"; expected "Type[bytes]"
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Error message seems to indicate it requires the type it is getting. I could be reading the error message wrong, but this one confuses me.
To Reproduce
- put the code in a file e.g. scratchpad.py
from typing import Type def f(class_type: Type[object]): if class_type in [bytes, bytearray]: return True - run
mypy scratchpad.py
Expected Behavior
no errors
Actual Behavior
scratchpad.py:4: error: List item 0 has incompatible type "Type[bytes]"; expected "Type[bytes]"
Your Environment
- Mypy version used: 0.790
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini(and other config files): n/a - Python version used: 3.8.3
- Operating system and version: OSX 10.15.7
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue の scratchpad.py の例に対して mypy を実行し、矛盾した Type[bytes] 診断を確認します。リストのメンバーシップ式に関係する型チェックの経路を追跡します。Expected Behavior に記載されているとおり、有効な例でエラーが報告されなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100