E306: False positive when preceded by 2 blank lines and a comment
まだ誰も着手していません。
評価
調査の方向性
提示された例を bug.py として保存し、pycodestyle --select=E306 --show-source bug.py を実行して、2 件の誤検知を再現します。プロジェクト唯一の Python ファイルにある E306 checker のエントリーポイントを読み、コメントと空行が前にあるネストされた定義で E306 が報告されなくなっていることを確認します。同時に、既存のケースが期待どおりの動作を維持していることも確認します。
索引モデルが issue の本文から書いたものです。
説明
$ pycodestyle --version
2.7.0
If you have two blank lines, a comment, and then a nested function, E306 is raised erroneously.
(Since this false positive requires a genuine violation of E303, I don't think it's a big deal. But I noticed it, so I'm reporting it.)
The following functions both trigger false postives for E306.
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 1/2)
pass
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 2/2)
pass
For context, this snippet contains the false positives as well as cases that don't trigger E306:
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 1/2)
pass
def bad():
_ = None
# arbitrary comment
def inner(): # E306 not expected (but happening! 2/2)
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
def good():
_ = None
# arbitrary comment
def inner(): # E306 not expected
pass
If you dump that to a file (e.g., bug.py) and run pycodestyle on it, you'll get E306 inside the two bad() functions:
$ pycodestyle --select=E306 --show-source bug.py
bug.py:7:5: E306 expected 1 blank line before a nested definition, found 0
def inner(): # E306 not expected (but happening! 1/2)
^
bug.py:16:5: E306 expected 1 blank line before a nested definition, found 0
def inner(): # E306 not expected (but happening! 2/2)
^
Let me know if there's anything I can clarify/provide, thanks!
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 760
- 平均マージ
- 8時間 11分
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PyCQA/pycodestyle のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
PyCQA/pycodestyle#1294 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
PyCQA/pycodestyle#1302 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
PyCQA/pycodestyle#1242 · コメント 2 件 ·
-
Spurious E231 for nested format substitutions再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
PyCQA/pycodestyle#1241 · コメント 2 件 · リアクション 4 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
PyCQA/pycodestyle#1217 ·
PyCQA/pycodestyle の issue をすべて見る
似ている issue
-
comp/cli P3 type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
NousResearch/hermes-agent#141420 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
vendor-pitch
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
bug llm p2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
New tool: ZIPZAX Python Notebook Studio対応中かも @github-actions が今日担当しました。 オープンsubmission triage
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
kausalflow/tools#226 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100