google / google/yapf

Add YAPF flag to always line-wrap dictionaries

Open
#1,002 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

I am on 0.28 version and have played around with the flags I can find but haven't found anything to 'force' line-wrapping. Specifically I think it would be reasonable for a new flag to allow dictionary statements to always line-wrap, vs I believe the current YAPF logic is to only 'process' line-wrapping configuration settings once a line exceeds the max character limit for a line. In other words, this new flag would enable whatever configuration a user specified for line-wrapping to be applied to ALL dictionaries, **even those lines under the max character limit**.

With an example, I would like to have this dictionary assignment appear as follows:

```
# DESIRED
value = {
"Components": [componentPlacement],
"Executives": [executive]
}
```

Currently, I am unable to find an acceptable* YAPF configuration to result in this multi-line format and instead i get it all on a single line (assuming it's length is less than **column_limit**):

```
# UNDESIRED
value = {"Components": [componentPlacement], "Executives": [executive]}
```

*As implied here, if i set **column_limit** small enough then the wrapping 'triggers' and works as desired, BUT I wish to in general have a longer line limit.

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.