Warn about certain sequences of chained comparisons
まだ誰も着手していません。
評価
調査の方向性
tensorflow/python/eager/function.py にリンクされている TensorFlow の例から始め、Python の連鎖比較のセマンティクスを確認してください。提案されている演算子ペアの制限を pyflakes の既存のチェックと比較し、意図的な連鎖比較と同等の式に必要な警告の動作およびカバレッジを定義してください。
索引モデルが issue の本文から書いたものです。
説明
I was pointed to this buggy line:
if x is None != y is None:
(For context, Python allows chaining any of the comparison operators ==, !=, is, is not, >, >=, <, <=, in, not in. a OP b OP c is equivalent to a OP b and b OP c except that b is only evaluated once.)
I find it hard to imagine a use case for combining is and != in the same chained comparison, so it would be useful for linters to warn about this and similar patterns.
In my company's internal linter, I implemented a check that disallows all chained comparison pairs except == + ==, is + is, </<= + </<=, and >/>= + >/>=.
It found one false positive where someone had intentionally written == + !=, but I'd argue it's clearer with and:
- value.fullName == existing.fullName != "*"
+ (value.fullName == existing.fullName and value.fullName != "*")
Would pyflakes be interested in a similar check?
- 主要言語
- Python
- スター
- 1.5k
- フォーク
- 205
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PyCQA/pyflakes のほかの issue
-
F542 is not a crimeオープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
-
Use of await in a function that is not async should be shown as a syntax error by flake8再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
micropython/micropython#19906 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
FinanceFlash/unvibecode#597 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
TomAnthony/YourOwnWeigh#21 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: Compliance rules never see Unity Catalog views as views対応中かも @wagnercsantos が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
databrickslabs/ontos#1348 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信