Black: Reflows of multiline blocks that have only one value don't include a comma

Created on 27 Jun 2018  路  3Comments  路  Source: psf/black

Operating system:
Python version: any
Black version: 18.6b4
Does also happen on master: yes

# formatted
var = [
    # A Thing that is very important oooooooooooooooooooo aaaaaaaaaaaaaaaaaaaa
    "VALUE"
]

I would expect that to insert a comma after "VALUE" for consistency with the expected output if there are multiple values, for example:

# example 2 formatted
var = [
    # A Thing that is very important oooooooooooooooooooo aaaaaaaaaaaaaaaaaaaa
    "VALUE",
    "OTHER",
]
comments duplicate enhancement

Most helpful comment

In general Black doesn't add the trailing comma for single-element lists, but I can see how it maybe should do so when the list is exploded due to a comment. Thanks for the report!

All 3 comments

In general Black doesn't add the trailing comma for single-element lists, but I can see how it maybe should do so when the list is exploded due to a comment. Thanks for the report!

Yup it's a edgy edge case.

We will address this. It's a duplicate of #274.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Curly-Mo picture Curly-Mo  路  3Comments

nottrobin picture nottrobin  路  3Comments

craigmac picture craigmac  路  3Comments

JelleZijlstra picture JelleZijlstra  路  3Comments

brettcannon picture brettcannon  路  3Comments