google / google/yapf

Add new line after logical operator

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

Description

Currently, I don't think there is a way to have each condition element to have their own line.
Additionally, the current formatting do not respect the `split_before_logical_operator`.
All condition get clustered like:
```py
if (
very_long_variable_name is not None and verrry_long_variable_name.field > 0
or very_long_variable_name.is_debugfs
):
pass
```
I would like to format my code as:
```py
if (
very_long_variable_name is not None
and verrry_long_variable_name.field > 0
or very_long_variable_name.is_debugfs
):
pass
```

My `.config/yapf/style`:
```ini
[style]
based_on_style = google
indent_width = 2
coalesce_brackets = True
dedent_closing_brackets = True
split_before_dot = True
split_before_logical_operator = True
```

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.