-
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
Black removes trailing commas from single element dicts #274
Comments
Yes, that will be fixed. |
This also happens with multi element (when short enough to span one line) functions |
@graingert, yes, this is where the bug stems from. That behavior will stay in calls and signatures for now as it's intentional and documented. I admit that it increasingly starts looking like an edge case as the style is evolving. We can revisit this later. |
@ambv I don't see the documentation for that |
oh you mean this:
|
Yes, and before you have an example with TracebackException that specifically demonstrates this behavior. |
I misunderstood because an argument list is not an expression |
Agreed, I try to be rather strict in vocabulary but that's not always easy. Some wording applies to both statements and expressions, some wording applies to argument lists, and so on. |
Ah I'd prefer behaviour that matched https://github.com/PyCQA/flake8-commas (obviously because I wrote it) then I can point people to use black instead |
To be fair this is only true for functions, because you only get 4 extra spaces when you split the parenth-form/list/dict/set literal, so I can see why you'd special case them.
|
@ambv any thoughts on which release this would be addressed? Thank you! |
The one this week. |
This does not include missing trailing commas due to a bug in black: psf/black#274
Hello @ambv, thank you so much for |
This seems to still be true, any plans on addressing? |
That will be fixed with #826. |
@ambv according to #826 (comment) by @durin42, this issue will not be fix in #826. |
An ugly workaround if you really need the trailing commas (specially in flake8) is to call |
Note that #826 will cause trailing commas to no longer be removed, but it won't add new ones if they're not needed (needed is complicated and I can't quite explain it clearly here, but hopefully that helps?) |
In cases like: data = {
"test": "test"
} flake8-commas complains of missing comma. It would be nice if |
The remaining issues here will be handled in #1288. |
I would expect Black to add trailing commas to multi-line dict/list/set/etc. literals with a single element, based on:
Operating system: OS X 10.11.6
Python version: 3.6.5
Black version: 18.5b1
Does also happen on master: yes, as of f471271
The text was updated successfully, but these errors were encountered: