google / google/yapf

Arrays broken before function call elements

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

Description

When breaking an array, yapf appears to treat array elements that are function calls differently from those that are not:

$ cat issue.py
array = [first, make_second(), third, fourth, fifth, make_sixth(), seventh, eighth]
$ yapf issue.py
array = [
first,
make_second(), third, fourth, fifth,
make_sixth(), seventh, eighth
]

This seems very strange to me. I'm not sure whether it's intended behavior or a bug, because I couldn't find a test for it or configuration option to disable it (I'd like to).

I would have expected either:

array = [
first, make_second(), third, fourth, fifth, make_sixth(), seventh, eighth
]

or:

array = [
first,
make_second(),
third,
fourth,
fifth,
make_sixth(),
seventh,
eighth
]

(ideally option A, I think; you can get option B already by adding a trailing slash)

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.