-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Different formatting of function call with and without trailing comma in arg list #1253
Comments
I believe this is a regression in 19.10b. I noticed this when I upgraded some of my projects recently. I notice mostly when doing refactoring where a multi-line arg list now fits on one line, as I delete several elements and black will often now produce things like myfunc(x, y, z,) which looks strange. I have no problem with the trailing comma being there (even though it looks weird to me), but either it needs to always be added, or it needs to be removed. Looking at the changelog, I wonder if maybe this was related to the positional-only argument handling? It's the only thing which sounds relevant, but that's just a guess. |
It's because of #826. |
Thanks for the link. It seems like this is on purpose, but #1169 makes it sound like this is a bug which is being fixed? But then the proposed fix doesn't seem to be a revert -- it's something else. So I'm confused about what's happening and whether or not this issue is being considered a bug. When wrapping a collection over multiple lines, For example, if you add to a collection with no trailing comma, making it wrap, then remove elements later, the result is not the same as removing elements first, then adding. |
AFAIK, this is an intended behavior of the magic trailing comma feature, and while the example from this issue also presents improper exploding, it has been fixed with #1288. |
Describe the bug
Black formats function call differently depending on whether the arg list has a trailing comma or not.
To Reproduce
Expected behavior
I would expect Black to format both of these the same - most likely in the way that second code snippet was formatted in.
Environment (please complete the following information):
Does this bug also happen on master?
Yes
Additional context
I imported the
builtins
module only so that the code is long enough to be split in multiple lines 😄The text was updated successfully, but these errors were encountered: