google / google/yapf

incorrect format with assert according to pep8

Open
#924 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

If there is a long statement having assert statement then, yapf is changing into format which is not consistent with [pep8 guidelines](https://www.python.org/dev/peps/pep-0008/#maximum-line-length).

sample.py
```
def someConditionTrue():
return True

class Foo():
def bar(self, longVar2):
longVar1 = 2
for _ in range(5):
if not True:
assert someConditionTrue(), "The condition if not true will print this {} and {}".format(longVar1, longVar2)
```

Command being run:
```
yapf --style='{based_on_style: pep8, indent_width: 2}' sample.py
```

Output begin generated:
```
def someConditionTrue():
return True

class Foo():
def bar(self, longVar2):
longVar1 = 2
for _ in range(5):
if not True:
assert someConditionTrue(
), "The condition if not true will print this {} and {}".format(
longVar1, longVar2)
```

Expected Output:
```
def someConditionTrue():
return True

class Foo():
def bar(self, longVar2):
longVar1 = 2
for _ in range(5):
if not True:
assert someConditionTrue(), \
"The condition if not true will print this {} and {}".format(
longVar1, longVar2)
```

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.