google / google/yapf

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

Open
#846 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

When using `{based_on_style: pep8, dedent_closing_brackets: true}` as a style, PEP 8's [indentation recommendation](https://www.python.org/dev/peps/pep-0008/#indentation) isn't followed when the test of an if statement is a logical expression.

Given the following `check.py`:
```py
if (
0X000000000000000000000000 or 0X000000000000000000000000
) and (
0X000000000000000000000000 or 0X000000000000000000000000
):
pass
```

Running `yapf --style "{based_on_style: pep8, dedent_closing_brackets: true}"` yields this output:
```py
if (0X000000000000000000000000 or 0X000000000000000000000000
) and (0X000000000000000000000000 or 0X000000000000000000000000):
pass
```

This raises [flake8's E125](https://www.flake8rules.com/rules/E125.html) ("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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.