yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Allow forcing newline after when training comma heuristic happens

Open ctheune opened this issue 3 years ago • 0 comments

This is about making lists with "one item per line" (triggered by the trailing comma heuristic) easy to sort (so the brackets need to be on separate lines) but I want other lists (no trailing comma) to have a compact "indentation signals nesting" style. I played around with various knobs but nothing helped...

I'm not sure whether I'm missing something why this would be a bad idea and I might be completely off. This could be related to #134, too.

The config currently is (short lines to help the example):

[style]
based_on_style = pep8
COLUMN_LIMIT = 30

And I get the following formatting:

def asdf():
    a = {
        "asdf": [
            1, 2, 3, 4, 5, 6,
            fdsafdsafdsafdsa,
            fdasfdasfdasfdsa,
            fdsafdsafdsa,
            fdsafdsa,
            afsdafdsa
        ]
    }

    b = [
        1,
        2,
        3,
        4,
        5,
        6,
        fd,
        fdsafdsafdsafdsa,
        fdasfdasfdasfdsa,
        fdsafdsafdsa,
        fdsafdsa,
        afsdafdsa,
    ]

What I would like to get is:

def asdf():
    a = {
        "asdf": [
            1, 2, 3, 4, 5, 6,
            fdsafdsafdsafdsa,
            fdasfdasfdasfdsa,
            fdsafdsafdsa,
            fdsafdsa,
            afsdafdsa]}

    b = [
        1,
        2,
        3,
        4,
        5,
        6,
        fd,
        fdsafdsafdsafdsa,
        fdasfdasfdasfdsa,
        fdsafdsafdsa,
        fdsafdsa,
        afsdafdsa,
    ]

ctheune avatar Jun 11 '21 09:06 ctheune