You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Black used to remove the trailing comma if the expression fits in a single line, but this was changed by #826 and #1288. Now a trailing comma tells Black to always explode the expression. This change was made mostly for the cases where you know a collection or whatever will grow in the future. Having it always exploded as one element per line reduces diff noise when adding elements. Before the "magic trailing comma" feature, you couldn't anticipate a collection's growth reliably since collections that fitted in one line were ruthlessly collapsed regardless of your intentions. One of Black's goals is reducing diff noise, so this was a good pragmatic change.
So no, this is not a bug, but an intended feature. The reason why you're filing this issue is probably since we say the following in the (outdated) style documentation:
Unnecessary trailing commas are removed if an expression fits in one line. This makes it 1% more likely that your line won't exceed the allotted line length limit. Moreover, in this scenario, if you added another argument to your call, you'd probably fit it in the same line anyway. That doesn't make diffs any larger.
We missed that this paragraph became incorrect when the "magic trailing comma" feature was introduced. It was eventually fixed in commit 6b935a3, but that was after the stable documentation was released alongside Black 20.8b1.
Anyway, here's the documentation on the "magic trailing comma". Hopefully that helps and sorry for the possible confusion.
To Reproduce Steps to reproduce the behavior:
Expected behavior I would expect this file to be formatted in the following way:
Environment
Does this bug also happen on master? yes
Remark
the following (without trailing comma after
c
) is formatted correclty:The text was updated successfully, but these errors were encountered: