python / python/mypy

Mypy should warn about conditions whose value can be deduced

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

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

feature
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Feature

Mypy can warn about left and right operands of conditions its value mypy can deduce. Unfortunately, it cannot do so for conditions consisting of one operand.

Pitch

val = 1337

if val is not None:
    pass

if val is not None and True:
    pass

Mypy can hint about the pointless left hand operand in the second if. Unfortunately, it does not do so for the first if. Supporting this use case would help the programmer to simplify her code by suggesting conditions to remove.

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

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

はじめの一歩

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

調査の方向性

and True の例における無意味な左辺オペランドに対する mypy の既存の診断から始め、その診断を生成している実装とテストを見つけてください。単一オペランドのケース if val is not None のカバレッジを追加し、既存の動作を後退させることなく、mypy が削除可能な条件を報告することを確認してください。

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

評価

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

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

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