Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank lines after import statements #4654

Closed
victor-torres opened this issue Jul 1, 2020 · 3 comments · Fixed by #5734
Closed

Blank lines after import statements #4654

victor-torres opened this issue Jul 1, 2020 · 3 comments · Fixed by #5734

Comments

@victor-torres
Copy link
Contributor

This issue was originated from a discussion on pull request #4434.

External resources

This is what the Blank Lines section from the PEP 8 proposes:

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).

Use blank lines in functions, sparingly, to indicate logical sections.

Python accepts the control-L (i.e. ^L) form feed character as whitespace; Many tools treat these characters as page separators, so you may use them to separate pages of related sections of your file. Note, some editors and web-based code viewers may not recognize control-L as a form feed and will show another glyph in its place.

In the same line as PEP 8, Google's Python Style Guide also only mentions top-level function and class definitions:

Two blank lines between top-level definitions, be they function or class definitions. One blank line between method definitions and between the class line and the first method. No blank line following a def line. Use single blank lines as you judge appropriate within functions or methods.

Our usage

Let's take the logger variable definition, something very common across Python projects, as an example.

In Scrapy, we have some differences (both valid according to PEP 8):

Apparently, Django is using only one blank line in this case.

Bottom line

What I'm trying to say is that there's no reference to this convention on the Scrapy's Coding Style, and IMO it's quite subjective.

TL; DR;

If this is important for the project to the point that we need to enforce it during code reviews, I propose we implement automatic code checks with a linter or at least document it in the Scrapy's Coding Style for future reference.

What do you think?

@stevenbrand99
Copy link

Hello, I would like to solve this one

@abc516
Copy link

abc516 commented Oct 5, 2021

Hi @Gallaecio @victor-torres is this issue still open / ready for work?

@Gallaecio
Copy link
Member

This is likely going to be addressed by #4658, which will be handled by core developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants