google / google/yapf

Line breaks around binary operators inconsistent with standards documentation

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

Description

A few years ago, [PEP 8](https://www.python.org/dev/peps/pep-0008/) updated the [rule](https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator) such that a line break should be before, not after, a binary operator. However, on https://github.com/google/yapf/blob/5e9520e04899b065616f2c53d9105d6b5352fd18/yapf/yapflib/style.py#L460, the relevant `SPLIT_BEFORE_ARITHMETIC_OPERATOR` is still `False` for the `pep8` style configuration. Is this inconsistent with the specification of PEP 8?

In addition, the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) does not override the [line breaking rule](https://google.github.io/styleguide/pyguide.html#indentation), and therefore should conform with the PEP 8 guideline in this area. However, https://github.com/google/yapf/blob/5e9520e04899b065616f2c53d9105d6b5352fd18/yapf/yapflib/style.py#L495-L497 further set `SPLIT_BEFORE_BITWISE_OPERATOR` and `SPLIT_BEFORE_LOGICAL_OPERATOR` to `False`. Is this also inconsistent with the standard specification?

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.