-
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
Splitting of a function across multiple lines doesn't add a trailing comma #346
Comments
This is because black can't detect that the file you're formatting is python3.6. Trailing commas are invalid syntax in some cases in older versions of python. If you run black with |
@zsol This is a function call, not a definition -- I can verify that this syntax is very much Python 2.7 compliant :) |
You're absolutely right, maybe I should read the code we're talking about ;) |
On this kind of split I'm not putting trailing commas because any change to line will result in the following:
In other words, the trailing comma doesn't add anything here. Better yet, it does up a character, making it more likely your arg list wouldn't fit in a single line. Does this explanation make sense? (note, we currently have a bug where a trailing comma is missing also from single-element collection literals that are exploded: #274; that will be fixed) |
Aren't the args to make_deferred_yieldable already exploded? The goal here is to be able to add new args to that call without touching existing lines. (I'd also argue that there should be a comma after _do_hash for consistency, but that is a different case and your logic is valid there) |
Yes, there is one argument and it doesn't fit in one line, hence there is a trailing comma at the level of this function. However, arguments to |
I think you are mistaken. Have another look at @hawkowl's report. |
Oh, yes, you're right. A single argument doesn't generate a trailing comma. I guess it should if that argument itself doesn't fit in one line. Good catch, we'll fix it! |
This will likely get solved with #826. |
This will be handled as part of #1288. |
Operating system: Arch Linux
Python version: 3.6.5
Black version: master
Does also happen on master: yes
Consider the following line (unformatted):
Black formats it as thus:
My coworker @richvdh gathers that it should be formatted with a trailing comma after the
threads.deferToThreadPool
call for consistency with how multi-line lists are formatted, producing the following:Is this something Black should do? PEP8's trailing comma examples don't really cover this specific case, so I'm not sure :)
The text was updated successfully, but these errors were encountered: