Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only the last trailing comma in a statement is magic #1671

Closed
andersk opened this issue Sep 3, 2020 · 4 comments · Fixed by #3370
Closed

Only the last trailing comma in a statement is magic #1671

andersk opened this issue Sep 3, 2020 · 4 comments · Fixed by #3370
Labels
F: trailing comma Full of magic T: bug Something isn't working

Comments

@andersk
Copy link

andersk commented Sep 3, 2020

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)

@andersk andersk added the T: bug Something isn't working label Sep 3, 2020
@ichard26 ichard26 added the F: trailing comma Full of magic label Sep 3, 2020
andersk added a commit to andersk/zulip that referenced this issue Sep 3, 2020
andersk added a commit to andersk/zulip that referenced this issue Sep 3, 2020
timabbott pushed a commit to zulip/zulip that referenced this issue Sep 4, 2020
Amitsinghyadav pushed a commit to Amitsinghyadav/zulip that referenced this issue Sep 20, 2020
@JelleZijlstra
Copy link
Collaborator

This is still broken (noting this because a similar bug with the magic trailing comma was fixed).

@thatlittleboy
Copy link

thatlittleboy commented May 1, 2022

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.

@JelleZijlstra JelleZijlstra changed the title Only the last trailing comma in a series of chained method calls is magic Only the last trailing comma in a statement is magic Jul 20, 2022
@JelleZijlstra
Copy link
Collaborator

#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.

@Toreno96
Copy link

Toreno96 commented Aug 4, 2022

What's the status of this issue? This is still broken on v22.6.0 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: trailing comma Full of magic T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants