-
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
Skip trailing comma by default #3273
Comments
This handling of trailing commas is intentional and this behavior is called "magic trailing comma", you can read about it here: |
@jack1142 Yes I know that Black doesn't reformat lines when there's a trailing comma. That doesn't mean that it's a good idea to add a comma when there wasn't one, esp. without an option to disable that behavior. |
I think this is a duplicate of #1742. The |
I'd be willing to entertain us flipping the toggle in preview and eventually altogether in v23. But this is just me personally 😅 Not collapsing small collections is more irritating to me than slightly larger diffs, although the config option is an easy fix. This would get us a step closer to our whole "not taking previous formatting into account" philosophy. Thoughts by other maintainers? |
I think its new title makes it a duplicate of #2135 instead! That one's accumulated a few thumbs-ups, so it seems there is at least some support for this amongst users (including me). (Not that that means particularly much; it's a rather biased sample.) |
Oh good find, I'll close this and post my message there as well 👍 |
Bug description
Changing line lengths is not reversible because Black adds a trailing comma to some argument lists.
To Reproduce
Reformatting with
--line-len=20
results inUnfortunately, due to the trailing comma after the
20
that wasn't there before, re-black
-ing with--line-length=80
doesn't undo this transformation.I have to manually remove the comma to get the old formatting back.
Expected behavior
Changing the line length from X to Y and back to X should be a no-op, at least for reasonable values of X and Y.
The text was updated successfully, but these errors were encountered: