reformatting some chained ternaries decreases their readability
Just a data point, I was surprised by how black treated my code: reformatting some chained ternaries decreases their readability.
To Reproduce
assert xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx == (
xxxxxxxxxxxxx if xxxxxxxxxxx == 0 else
xxxxxxxxxxxxxxxxxx if xxxxxxxxxxx == 1 else
xxxxxxxxxxxxxxxxxxxx
)
is reformatted as:
assert xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx == (
xxxxxxxxxxxxx
if xxxxxxxxxxx == 0
else xxxxxxxxxxxxxxxxxx if xxxxxxxxxxx == 1 else xxxxxxxxxxxxxxxxxxxx
)
which no longer has the structure that was present in to first. (If only we had match expressions in Python.)
Thanks for the input! The style of breaking ternaries before the else is intentional, as opposed to after the else in your preferred style. Had the else clause been a bit longer the second else would also get split into its own line.
Nonetheless I appreciate the data point.
(p.s. I did end up starting a discussion on match expressions on the discuss forum, feel free to add your thoughts there, maybe we'll see something come out of it!)