yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Prevent double indenting when splitting function parameters in if or with

Open char101 opened this issue 4 years ago • 3 comments

Hi, is this supported by yapf configuration if I want to prevent the function parameters from being indented twice in this case:

if func(
    a,
    b,
):
    pass

Output:

if func(
        a,
        b,
):
    pass

Desired output:

if func(
    a,
    b,
):
    pass

I can get the output that I want by changing https://github.com/google/yapf/blob/main/yapf/yapflib/format_decision_state.py#L980 from

return token_indent + style.Get('CONTINUATION_INDENT_WIDTH')

to

return token_indent

But I wonder if this is configurable.

char101 avatar Dec 15 '21 15:12 char101

Looks like I have the opposite issue: https://github.com/google/yapf/issues/843 ; maybe you find something helpful in this ticket and its links.

sinoroc avatar Jan 16 '22 15:01 sinoroc

It's only when CONTINUATION_INDENT_WIDTH = 4 ): DEDENT_CLOSING_BRACKETS = true solved it in function definition but not in function call

NoamNol avatar Jun 22 '22 10:06 NoamNol