PyCQA / pycodestyle

Simple Python style checker in one Python file
https://pycodestyle.pycqa.org
Other
5.01k stars 754 forks source link

E131: Missing lint for inconsistent indentation #667

Open asottile opened 7 years ago

asottile commented 7 years ago

I expect some kind of error here, but none is produced:

f = x = y = z = 1
f(x,
    y,
  z)

perhaps E131 continuation line unaligned for hanging indent?

jfhc commented 6 years ago

From my understanding of Pep 8:

When using a hanging indent the following should be considered; there should be no arguments on the first line...

E131 isn't appropriate because neither of the continuation lines should be hanging because there's an argument on the first line.

I'm working on a little patch for this which checks whether a new opening parenthesis is immediately followed by a newline; if not, don't allow for hanging indents. My patched version now complains about line 3 (the y, line) with E127: continuation line over-indented for visual indent.

However, I have a bug and some of the unit tests fail with my changes.

I'll come back to it and try to sort it out soonish, but in the meantime if anyone wants to look at how I've been trying to do it and offer any feedback/fixes, here's my branch where I'm working on it.