E303: too many blank lines (2)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by locating the E303 check and reviewing how its current blank-line limit is tested. Compare the proposed exception-count and configurable-limit options with the PEP 8 wording, then clarify the intended policy with maintainers before implementing anything. Done means a decided behavior and tests covering the accepted cases.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 765
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/pycodestyle
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
PyCQA/pycodestyle#1294 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
PyCQA/pycodestyle#1302 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
PyCQA/pycodestyle#1242 · 2 comments ·
-
Spurious E231 for nested format substitutionsMay be free again @inchang-ing claimed this 34 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
PyCQA/pycodestyle#1241 · 3 comments · 4 reactions ·
-
`exclude` is applied to `.`May be free again @OnlineBunker claimed this 12 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
PyCQA/pycodestyle#1217 · 3 comments ·
All issues in PyCQA/pycodestyle
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Library sweep logs an ERROR at start for the valkey instrumentor when valkey-py is not installedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
JoahanMorales/upiixia-agentic-kit#99 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100