google / google/yapf

"continuation line over-indented for hanging indent" with 0.27 (multi ".format" on same line)

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

Here is a snippet of code with the way I usually indent:
```python
class MyClass():
def __str__(self):
change_str = self.FMT_TITLE.format(
property_name='{0}{1}'.format(' ' * self.sub_level,
self.property_name),
before='',
after='',
action=self.action)
```

Given the default configuration:
```
[style]
based_on_style = pep8
column_limit = 100

align_closing_bracket_with_visual_indent = true
blank_line_before_class_docstring = true
blank_line_before_module_docstring = true
blank_line_before_nested_class_or_def = true
```

0.27 will reindent like this:
```
class MyClass():
def __str__(self):
change_str = self.FMT_TITLE.format(property_name='{0}{1}'.format(
' ' * self.sub_level, self.property_name),
before='',
after='',
action=self.action)
```
that causes a flake8 error: E126 continuation line over-indented for hanging indent.

For me, the right indentation in this case is:
```python
class MyClass():
def __str__(self):
change_str = self.FMT_TITLE.format(
property_name='{0}{1}'.format(
' ' * self.sub_level, self.property_name),
before='',
after='',
action=self.action)
```

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.