Skip to content
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

Remove trailing comma in function definition on single line #725

Closed
JelleZijlstra opened this issue Feb 25, 2019 · 6 comments
Closed

Remove trailing comma in function definition on single line #725

JelleZijlstra opened this issue Feb 25, 2019 · 6 comments
Labels
F: trailing comma Full of magic T: style What do we want Blackened code to look like?

Comments

@JelleZijlstra
Copy link
Collaborator

I would have expected

def f(x,):
    pass

to have its comma removed by Black, but that doesn't happen.

I think we should always remove the trailing comma if the function arguments fit on a single line.

(I ran into this when I removed a function's second argument and relied on Black to get rid of the trailing comma.)

@JelleZijlstra JelleZijlstra added the T: style What do we want Blackened code to look like? label May 5, 2019
@ambv
Copy link
Collaborator

ambv commented Mar 4, 2020

Yes, that annoys me, too.

@ambv ambv added the stable label Mar 4, 2020
@ambv
Copy link
Collaborator

ambv commented Mar 4, 2020

Is this related to #1288?

@felippemr
Copy link

Do we have a pr for this already? I can create one if needed.

@marctorsoc
Copy link

marctorsoc commented Aug 25, 2020

is this now solved? @JelleZijlstra @ambv

@mcsitter
Copy link
Contributor

mcsitter commented Sep 8, 2020

On master this has not been solved. I also can't see a PR for this issue. I think it would great if @felippemr could open one if he is still up for it?

@ichard26
Copy link
Collaborator

Closing as this issue doesn't make sense anymore after #826 and #1612 landed. The trailing comma will never be removed as it now has special meaning to Black. It is now a "magic" trailing comma and will cause the function parameter list to be exploded by Black.

def f(x,):
    pass

will be formatted (by Black 20.8b1) to:

def f(
    x,
):
    pass

For the reader who has randomly stumbled across this issue and wants to know about the "magic trailing comma" feature, please read its documentation.

@ichard26 ichard26 added the F: trailing comma Full of magic label Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: trailing comma Full of magic T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

6 participants