yapf icon indicating copy to clipboard operation
yapf copied to clipboard

The dedent_closing_brackets setting conflicts with PEP 8's indentation recommendation (E125)

Open tschaub opened this issue 5 years ago • 2 comments

When using {based_on_style: pep8, dedent_closing_brackets: true} as a style, PEP 8's indentation recommendation isn't followed when the test of an if statement is a logical expression.

Given the following check.py:

if (
    0X000000000000000000000000 or 0X000000000000000000000000
) and (
    0X000000000000000000000000 or 0X000000000000000000000000
):
    pass

Running yapf --style "{based_on_style: pep8, dedent_closing_brackets: true}" yields this output:

if (0X000000000000000000000000 or 0X000000000000000000000000
    ) and (0X000000000000000000000000 or 0X000000000000000000000000):
    pass

This raises flake8's E125 ("continuation line with same indent as next logical line").

I've tried adding continuation_align_style: 'VALIGN-RIGHT' to the style, but get the same result.

See also:

  • #21 (continuation in if statement)
  • #196 (continuation in function parameters)
  • #197 (continuation in for statement)
  • #453 (continuation in async with statement)
  • #585 (continuation in for statement)
  • #600 (continuation in except clause)

Version: yapf 0.30.0

tschaub avatar Jul 21 '20 18:07 tschaub

is there any updates for this problem? I am using yapf 0.32.0

elashrry avatar Jan 12 '23 10:01 elashrry

I am using yapf==0.40.0, this problem still exists.

SWHL avatar Jun 19 '23 03:06 SWHL