google / google/yapf

Inconsistent line break before opening bracket of a list inside a dictionary

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

Description

This is the result of reformatting lists inside a dictionary:
```
x = {
"A":
[
"--------------------------------------------------X",
"--------------------------------------------------X",
],
"B": [
"--------------------------------------------------X",
"--------------------------------------------------",
],
"C":
[
"-----------------------",
"-----------------------X",
"-----------------------X",
"-----------------------",
],
"D": [
"-----------------------",
"-----------------------X",
"-----------------------",
"-----------------------",
],
}
```

Lists B and D have opening brackets on the same line as the key, but A and C don't.
It seems to be related to the number of items and their length as illustrated by adding 1 vs. 2 characters to items in otherwise identical lists.

`yapf==0.22.0`

setup.cfg:
```
based_on_style=pep8
column_limit=120
dependent_closing_brackets=true
indent_dictionary_value=true
```

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.