black icon indicating copy to clipboard operation
black copied to clipboard

Trailing comma for function with one arg

Open cosinequanon opened this issue 7 years ago • 4 comments

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==

cosinequanon avatar Jun 02 '19 16:06 cosinequanon

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

def one(a):
    pass

zsol avatar Jun 02 '19 18:06 zsol

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 avatar Jun 09 '19 06:06 djb7

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

Jma353 avatar Aug 04 '19 17:08 Jma353

yep.

zsol avatar Aug 05 '19 09:08 zsol