Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

E303: too many blank lines (2)

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

まず 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 はありません

環境構築

はじめの一歩

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

PyCQA/pycodestyle のほかの issue

PyCQA/pycodestyle の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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