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

Comma at end of assignment changes output with 23.3.0 #3720

Closed
daveisfera opened this issue Jun 5, 2023 · 4 comments
Closed

Comma at end of assignment changes output with 23.3.0 #3720

daveisfera opened this issue Jun 5, 2023 · 4 comments
Labels
T: style What do we want Blackened code to look like?

Comments

@daveisfera
Copy link

This code is a little odd, but before it left it as is and now with 23.3.0, the output is changed

def changes(a, b, c="C", **kwargs):
    z, y = kwargs["a"], kwargs["b"]
    x, w, v, = (
        "X",
        "W",
        "V",
    )

def stays(a, b, c="C", **kwargs):
    z, y = kwargs["a"], kwargs["b"]
    x, w, v = (
        "X",
        "W",
        "V",
    )

With 22.x, these would both be left as is, but with 23.3.0, the changes function is changed to a tuple that spans multiple lines for the assigned to values

@daveisfera daveisfera added the T: style What do we want Blackened code to look like? label Jun 5, 2023
@JelleZijlstra
Copy link
Collaborator

The new behavior is correct. This comma is treated as a magic trailing comma (https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#the-magic-trailing-comma).

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2023
@daveisfera
Copy link
Author

Doesn't that go against the concept of cede control over minutiae of hand-formatting? Basically, if a comma is accidentally left at the end of a tuple, then completely different output is received. Should the output be the same regardless of minor modifications by a human?

@JelleZijlstra
Copy link
Collaborator

It kind of does! The magic trailing comma isn't a feature I'm particularly happy with and I may want to turn it off by default (#2135), but now that we have it, we should apply it consistently.

@daveisfera
Copy link
Author

Sounds good! Thanks for the info and all your work on black

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

2 participants