E127: "continuation line over-indented" when comprehension is an argument #680
Description
Consider
[obj for obj in iterator
if some_long_cond()
and some_other_cond()]
(obj for obj in iterator
if some_long_cond()
and some_other_cond())
sorted(obj for obj in iterator
if some_long_cond()
and some_other_cond())
I would consider that this is a reasonable, and perhaps even the correct way to indent such expressions, assuming you adhere to the "binary operators after linebreak" school and also assuming that the expressions are too long to fit in a single line.
Interestingly, pycodestyle is happy with the indenting of the first two expressions, but complains about the last one
test.py:9:11: E127 continuation line over-indented for visual indent
(Note that it is able to recognize the correct amount of indenting needed in the first two expressions -- adding or removing a space before "and" results in the same warning as for the third expression.)
Edit: note to self or whoever will work on this: the first two cases actually work "accidentally" because the indent of the last line is 4 characters, which is always accepted -- prepending the thing e.g. with the_list = [...
and indenting the rest to align makes the thing fail again.)