Open MarkusPiotrowski opened 4 years ago
Both of your examples increase vertical space use. Black prefers to split by operator if there's more than one, otherwise it leads to a myriad of pathological cases. We've tried always splitting on operators, it's less code actually. But testing with large bodies of source code, this wound up being worse on average.
I'm not closing this yet as I do feel we have tackle this somehow.
Very much related to #2156 as well.
This is similar to other issues like #571, #587, #1050 and #1094.
Black should prefer line-breaking at binary operators over function parentheses or index/slice parentheses of one of the expression's elements. Especially in multi-element expression (e.g. calculations), the code becomes hard to read.
I have even seen worse examples than the two below, where a calculation becomes impossible to follow. But I think these two examples are quite clear.
Examples in the current Black style
Desired style How do you think Black should format the above snippets: