google / google/yapf

Splitting before logical operator in bracketed `if` conditions

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

Description

```properties
# setup.cfg
based_on_style = pep8
column_limit = 50
split_before_logical_operator = True
split_penalty_logical_operator = 0
```

Let`s consider we have such code after yapf 0.28.0 formatting:
```python
# 1
if (variable1.aaa == 1
and variable1 == variable2):
pass

# 2
if ((variable1.aaa == 1) and
(variable1 == variable2)):
pass
```

While # 1 is styled as expected, I cannot understand why in # 2 line is not splitting before `and`. Also it would be preferably in # 2 to have same indentation for second line as in # 1

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.