Direction of comparison operator in error message does not depend on direction in code
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
Bug Report
When encountering an error due to using a comparison operator with None as one of the arguments, Mypy adjusts the direction of < and > operators in its messages based on the types involved so that it always reports None as the second type (e.g. Unsupported operand types for {comparisson operator direction} ("int" and "None")). This becomes increasingly confusing when both variables in the comparison could potentially be a large number of types.
To reproduce
For the following code
1 < None
1 > None
None < 1
None > 1
Expected Behavior
file.py:1: error: Unsupported operand types for < ("int" and "None") [operator]
file.py:2: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:3: error: Unsupported operand types for < ("None" and "int") [operator]
file.py:4: error: Unsupported operand types for > ("None" and "int") [operator]
Actual Behavior
file.py:1: error: Unsupported operand types for < ("int" and "None") [operator]
file.py:2: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:3: error: Unsupported operand types for > ("int" and "None") [operator]
file.py:4: error: Unsupported operand types for < ("int" and "None") [operator]
Your Environment
- Mypy version used: 1.10
- Python version used: 3.12
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、mypy 1.10 で issue にある4つの比較ケースを再現し、次に、サポートされていないオペランド型をフォーマットする診断パスを追跡します。両方のオペランド順序についてリグレッションカバレッジを追加し、各メッセージが期待される出力に示されたソース演算子とオペランド順序を保持することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100