You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
break in expression* => break the for and the if (edit: this is implied by 2.).
break the for => break the if.
*This should add a continued_indent.
.1. seems obvious to me, I can see 2. being slightly more controversial...
To give a silly example:
# current
["This is a list comprehension which is quite long, I want it to split" +
"a second long string pushes this over 79" for i in range(3) if i == 1]
# one possible
["This is a list comprehension which is quite long, I want it to split" +
"a second long string pushes this over 79"
for i in range(3) if i == 1]
# my suggestion
["This is a list comprehension which is quite long, I want it to split" +
"a second long string pushes this over 79"
for i in range(3)
if i == 1]
# autopep8
["This is a list comprehension which is quite long, I want it to split" +
"a second long string pushes this over 79" for i in range(3) if i == 1]
It's not a bad heuristic, I think. Though figuring out if there's a break in the expression might be complicated. The current way to figure out if a split occurred previous to the list comprehension is to backtrack through the tokens to find a split, which is sucky behavior if not done carefully.
FWIW, I'd strongly prefer to be able to break before the "for" and "if" statements in a list comprehension, even if they could be packed to a single line, unless the whole thing fits on a single line. (and even then, I prefer separating them, because it matches better the "one statement per line" model of Python code, IMO, but I realise that's personal taste related.)
My suggestion is the following:
and the if (edit: this is implied by 2.).*This should add a continued_indent.
.1. seems obvious to me, I can see 2. being slightly more controversial...
To give a silly example:
I realise @gwelymernans is working on list comprehensions, but thought I should punt this as an issue.
The text was updated successfully, but these errors were encountered: