yapf icon indicating copy to clipboard operation
yapf copied to clipboard

split_complex_comprehension in v0.33.0 is not consistent with v0.32.0

Open tamaralyne opened this issue 2 years ago • 3 comments
trafficstars

Attempting to format code with v0.33.0

def test():
    test = {
            key_long_var: [i
                           for i in val_long_var]
            for key_long_var, val_long_var in data.items()
    }

However, using v0.32.0

def test():
    test = {
            key_long_var: [i for i in val_long_var]
            for key_long_var, val_long_var in data.items()
    }

I am expecting the results in v0.32.0.

This is the yapf arguments that I am using:

yapf --recursive --verbose --in-place --no-local-style --style="{dedent_closing_brackets: True, continuation_indent_width: 8, split_complex_comprehension: True}" .

tamaralyne avatar Jun 08 '23 19:06 tamaralyne

Repro:

0.33.0

$ pipx run --spec="yapf==0.33.0" yapf --no-local-style --style="{split_complex_comprehension: True}" 2> /dev/null <<EOF
def test():
    test = {
            key_long_var: [i
                           for i in val_long_var]
            for key_long_var, val_long_var in data.items()
    }
EOF
def test():
    test = {
        key_long_var: [i
                       for i in val_long_var]
        for key_long_var, val_long_var in data.items()
    }

0.32.0

$ pipx run --spec="yapf==0.32.0" yapf --no-local-style --style="{split_complex_comprehension: True}" 2> /dev/null <<EOF
def test():
    test = {
            key_long_var: [i
                           for i in val_long_var]
            for key_long_var, val_long_var in data.items()
    }
EOF
def test():
    test = {
        key_long_var: [i for i in val_long_var]
        for key_long_var, val_long_var in data.items()
    }

Spitfire1900 avatar Jun 16 '23 17:06 Spitfire1900

Confirmed this persists with 0.40.0

Spitfire1900 avatar Jun 16 '23 17:06 Spitfire1900

Git bisected that bb2baba5c2bb645a88f78d0173b3f43780cfb6a0 introduced the change.

Spitfire1900 avatar Jun 16 '23 17:06 Spitfire1900