google / google/yapf

Is there a way to `ALLOW_MULTILINE_LISTS`?

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

Description

Hi,

Similar to `ALLOW_MULTILINE_DICTIONARY_KEYS`, I would like YAPF to preserve the formatting of list items that have been declared on individual lines, e.g.

```py
def ui(self, gr):
return [
gr.Textbox(label="Conditional statement 🡢 my_var", max_lines=1),
gr.Dropdown(label="Evaluation method 🡢 _is", choices=["==", "!=", "<", "<=", ">", ">="], value="=="),
gr.Checkbox(label="Invert evaluation such that a true statement will return false 🡢 _not"),
gr.Checkbox(label="Return true if any one of multiple conditions are true 🡢 _any")
]
```

As far as I can tell, the only ways to achieve this would be to adjust the `COLUMN_LIMIT` (which would have side effects) or to wrap this block in `# yapf: disable / enable` comments. Is there a cleaner solution?

Thank you. Love your formatter.

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.