black
black copied to clipboard
Indexing square brackets split on 3 lines
Describe the style change I have an assert statement that checks a condition on the last element in an array. To me what black does to the statement makes it less readable:
assert self.ref_transitions[-1].terminal.all(), "Last ref transition must be terminal."
Examples in the current Black style
assert self.ref_transitions[
-1
].terminal.all(), "Last ref transition must be terminal."
Desired style
assert (
self.ref_transitions[-1].terminal.all()
), "Last ref transition must be terminal."
# OR
assert self.ref_transitions[-1].terminal.all(), (
"Last ref transition must be terminal."
)
Additional context
I think operation of taking [-1]th element is best visible with brackets and number grouped. Having to search them across a diagonal on 3 lines is tough.
Hi! The bracket break is tracked in #236, and assert formatting in #348. Therefore this could be considered a duplicate, if you think they satisfy your style proposal!
As @felix-hilden said this is a duplicate of various older issues.