black
black copied to clipboard
Only the last trailing comma in a statement is magic
I would expect this to be left alone by the magic trailing comma rule:
zero(
one,
).two(
three,
).four(
five,
)
But Black implodes it to
zero(one,).two(three,).four(
five,
)
Environment (please complete the following information):
- Version: 20.8b1
- OS and Python version: Linux/Python 3.8.5
Does this bug also happen on master? Yes (playground)
This is still broken (noting this because a similar bug with the magic trailing comma was fixed).
This is still broken on v22.3.0. Does anybody have any workarounds?
The only thing I can do now is to put parentheses around the method calls, then black
will format the example in the original post like this:
(
zero(
one,
)
.two(
three,
)
.four(
five,
)
)
Or maybe to kickstart potential PRs, can any black
maintainer point us to the rough area in the codebase to look at which is causing this issue? Thanks.
#2498 has some examples showing this is more general: if a statement contains multiple magic trailing commas, the magic only extends to one of them.
What's the status of this issue? This is still broken on v22.6.0
😞