Python version: 3.6.4
Black version: 18.4a0
Does also happen on master: yes
It's a little difficult to explain my problem. But I think the example below should be clear.
what black outputs:
a_function_who_return_a_list(
"a really really really really really long string with one line"
)[
0
]
a_function_who_return_a_function(
"""a string with
two lines"""
)(
"argument"
)
what I expect:
a_function_who_return_a_list(
"a really really really really really long string with one line"
)[0]
a_function_who_return_a_function(
"""a string with
two lines"""
)("argument")
This is an effect of Black's algorithm which looks for the right-most bracket first and splits by that. If that didn't help, it looks further left and splits by those brackets. And so on, and so on.
I agree your hand-formatted examples look nicer but I don't quite know what simple and deterministic algorithm to use to split nicer. Note that "splitting from the left" also doesn't work because that would end up with strange-looking formatting like:
some_dict[
'key'
] = some.very.long.value()
This is fixed by 3eea3aad864b83af3b6c477c32f15eb821fe9341! 馃嵒
Most helpful comment
This is fixed by 3eea3aad864b83af3b6c477c32f15eb821fe9341! 馃嵒