google / google/yapf

odd splits with func and methods

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

Description

This is pretty obscure syntax, but it came up in a repo I tried to apply yapf to:
```
some_string = 'val1,val2 val3,val4'

foo1 = {
'bar1': filter(len, some_string.split(' ').split(',')),
}

foo2 = {
'bar2': filter(len, some_string.split(' ')),
}
```
Not great code in the first place, but this is what the default yapf config formats it to:
```
some_string = 'val1,val2 val3,val4'

foo1 = {
'bar1': filter(len,
some_string.split(' ').split(',')),
}

foo2 = {
'bar2': filter(len, some_string.split(' ')),
}
```
The hanging line in foo1['bar1'] seems like an unintended result, both in the appearance and splitting in general, since the line isn't hitting a column limit-- am I missing something? I tried a bunch of different options to get rid of that split + hang but couldn't find one.

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.