elethan
elethan

Reputation: 16993

Make Pylint care about blank lines

I am not a stickler for most things pep-8, but certain things I personally prefer when writing code (as opposed to for work, where I would adhere to the style or lack thereof of the existing code base).

One thing I personally tend to follow is pep-8's suggestion about blank lines:

Surround top-level function and class definitions with two blank lines.

Method definitions inside a class are surrounded by a single blank line.

However, I have not been able to get Pylint to warn me when I violate this. I don't see anything that seems relevant disabled in my .pylintrc, and I have not been able to figure out if this is possible in Pylint, and if so, how to enable it.

Based on this answer, it looks like there are certain aspects of pep-8 that Pylint does not (or did not at the time) cover, but I have not been able to ascertain whether this is the case for blank lines.

Is it possible to have Pylint warn about blank lines (too many/not enough) without writing custom extensions?

Upvotes: 18

Views: 4249

Answers (1)

tbobm
tbobm

Reputation: 123

As mentioned in this other answer, E301 and E303 doesn't seem to be a thing in pylint (yet?).

One alternative would be to use the pycodestyle (previously: pep8) tool directly, which would allow you to check for blank lines.

Hopefully you'll like it as much as pylint, despite maybe being a little bit less configurable.

Upvotes: 3

Related Questions