Inconsistent line splitting when function argument is a dictionary
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
When formatting the code below with `yapf --style=pep8`:
```python
if a:
if b:
if e.response.get('Error', {}).get('XXXX')[0] == '4' and e.xxxxxxxxx_xxxx == 'XXXXXXXXXX':
pass
if a:
if b:
if e.response.get('Error', xy).get('XXXX')[0] == '4' and e.xxxxxxxxx_xxxx == 'XXXXXXXXXX':
pass
```
produces
```python
if a:
if b:
if e.response.get(
'Error',
{}).get('XXXX')[0] == '4' and e.xxxxxxxxx_xxxx == 'XXXXXXXXXX':
pass
if a:
if b:
if e.response.get(
'Error',
xy).get('XXXX')[0] == '4' and e.xxxxxxxxx_xxxx == 'XXXXXXXXXX':
pass
```
which is inconsistent, as in the first case the dictionary has a different indentation as the `xy` variable.
Also, the generated code has the following PEP8 violations:
```
test2.py:5:5: E129 visually indented line with same indent as next logical line
test2.py:5:13: E131 continuation line unaligned for hanging indent
```
yapf version: 0.22.0
Contributor guide
Assessment
This issue has not been assessed yet.