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
This also happens with the set literal {"some_key", "some_value", "other_key", "other_value",} and the list literal ["some_key", "some_value", "other_key", "other_value",].
Run Black on it with these arguments black black_test.py
See error: the file is unchanged
Expected behavior
Based on the documentation on trailing commas, I would expect the final comma after "other_value" to be removed.
Unnecessary trailing commas are removed if an expression fits in one line.
This case doesn't match either of the stated exceptions: it is neither a tuple expression with one element nor a function signature with a *.
Now, you can communicate that you don't want [the literal collapsed to one line] by putting a trailing comma in the collection yourself. When you do, Black will know to always explode your collection into one item per line.
Environment (please complete the following information):
Version: 19.10b0, installed via pipx
OS and Python version: macOS 10.15.4 with Python 3.8.2 installed via pyenv
Does this bug also happen on master? Yes: tested on the Black Playground
The text was updated successfully, but these errors were encountered:
Describe the bug Trailing commas are left in collections that remain on one line in a function call
To Reproduce Steps to reproduce the behavior:
This also happens with the set literal
{"some_key", "some_value", "other_key", "other_value",}
and the list literal["some_key", "some_value", "other_key", "other_value",]
.black black_test.py
Expected behavior
Based on the documentation on trailing commas, I would expect the final comma after
"other_value"
to be removed.This case doesn't match either of the stated exceptions: it is neither a tuple expression with one element nor a function signature with a
*
.Based on the documentation on the magic trailing comma, I would expect the dictionary literal to be expanded to multiple lines.
Environment (please complete the following information):
Does this bug also happen on master? Yes: tested on the Black Playground
The text was updated successfully, but these errors were encountered: