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

Trailing comma for function with one arg #880

Closed
cosinequanon opened this issue Jun 2, 2019 · 4 comments
Closed

Trailing comma for function with one arg #880

cosinequanon opened this issue Jun 2, 2019 · 4 comments
Labels
F: trailing comma Full of magic T: bug Something isn't working

Comments

@cosinequanon
Copy link

cosinequanon commented Jun 2, 2019

A function with one argument keeps the trailing comma but if there are two it is stripped.

In:

def one(
    a,
):
    pass

def two(
    a,
    b,
):
    pass

Out

def one(a,):
    pass


def two(a, b):
    pass

From https://black.now.sh/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4ACGAFNdAD2IimZxl1N_WlbvK5V-4TOOTwYyJEleH-JCdis69M0BXQy1O1PWCxUpRscYAufHo8BjrjIj1dM6YL_cyWPemFXxt1cpBhl0f8lWpI3sZ5u99cYAAACFuqAGuJSBnwABb4cBAAAAtWKNgbHEZ_sCAAAAAARZWg==

@zsol zsol added T: bug Something isn't working F: trailing comma Full of magic labels Jun 2, 2019
@zsol
Copy link
Collaborator

zsol commented Jun 2, 2019

That's a bug, one should be formatted like so:

def one(a):
    pass

@psf psf deleted a comment Jun 7, 2019
djb7 added a commit to djb7/black that referenced this issue Jun 9, 2019
Modified maybe_remove_trailing_comma to remove trailing commas for
typedarglists (in addition to arglists), and updated line split logic
to ensure that all lines in a function definition that contain only one
arg have a trailing comma.
@djb7
Copy link
Contributor

djb7 commented Jun 9, 2019

I made pull request #891 with a potential fix. Please let me know if the approach makes sense and if you have any suggestions for improvement.

djb7 added a commit to djb7/black that referenced this issue Jun 9, 2019
Modified maybe_remove_trailing_comma to remove trailing commas for
typedarglists (in addition to arglists), and updated line split logic
to ensure that all lines in a function definition that contain only one
arg have a trailing comma.
djb7 added a commit to djb7/black that referenced this issue Jun 10, 2019
Modified maybe_remove_trailing_comma to remove trailing commas for
typedarglists (in addition to arglists), and updated line split logic
to ensure that all lines in a function definition that contain only one
arg have a trailing comma.
JelleZijlstra pushed a commit that referenced this issue Jun 15, 2019
Modified maybe_remove_trailing_comma to remove trailing commas for
typedarglists (in addition to arglists), and updated line split logic
to ensure that all lines in a function definition that contain only one
arg have a trailing comma.
@Jma353
Copy link
Contributor

Jma353 commented Aug 4, 2019

Looks like this was fixed in 9394de1. Can this be closed?

@zsol
Copy link
Collaborator

zsol commented Aug 5, 2019

yep.

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: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants