E303: too many blank lines (2)
まだ誰も着手していません。
評価
調査の方向性
まず E303 チェックの場所を特定し、現在の空行の上限がどのようにテストされているかを確認します。提案されている例外数のカウントと設定可能な上限のオプションを PEP 8 の記述と比較し、そのうえで何も実装する前に、意図するポリシーをメンテナーと明確にします。完了条件は、動作が決定され、受け入れられるケースを網羅するテストがあることです。
索引モデルが issue の本文から書いたものです。
説明
quoting PEP 8 :
"Surround top-level function and class definitions with two blank lines.
Method definitions inside a class are surrounded by a single blank line.
Extra blank lines may be used (sparingly) to separate groups of related functions. Blank lines may be omitted between a bunch of related one-liners (e.g. a set of dummy implementations)."
Which may be usefull, for example, if you are used to split your function in really small unit accordingly to the SRP (and Clean Code book of Robert C. Martin).
For example if you have a snippet like this one, with a lot more of subfunction :
class foo():
def usefull_function(self):
_sub_function_a()
_sub_function_b()
def _sub_function_a(self):
#do_stuff
def _sub_function_b(self):
#do_stuff
def other_function_with_subfunction(self): # Two blank lines before this might be cleaner.
_sub_function_c()
_sub_function_d()
def _sub_function_c(self):
#do_stuff
def _sub_function_d(self):
#do_stuff
This snippet is here to give an example of why this can be used, but anyway, the PEP states it's ok.
Question :
- Should pycodestyle allow more blank lines that the recommandation (and not restriction)?
Options that could be implemented
- Selecting the number of exception to the recommandation that can be applied to a class (enhance the "sparingly" in the PEP8 quotation)
- Selecting the max number of extra blank line before class, top-level function and method.
Pros :
- Real check of the PEP8.
- Let you more option for clean code.
Cons :
- In the main use case, you want only one blank line before a def, and it will allow some wrong blank space to sneak in the code.
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 756
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- 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 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
PyCQA/pycodestyle#1241 · コメント 2 件 · リアクション 4 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
PyCQA/pycodestyle#1217 ·
PyCQA/pycodestyle の issue をすべて見る
似ている issue
-
repo-audit
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
scverse/repo-health#20 ·
メンテナーはふだん 1 日以内に返信
-
/context/prime scope override double-prefixes an entity-ref project and drops its scoped memoriesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
phasespace-labs/palinode#232 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
collective/icalendar#1858 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
langflow-ai/langflow#15496 ·
メンテナーはふだん 1 日以内に返信