google / google/yapf

Dictionary key/values being seperated onto new lines in complex dictionary?

Open
#762 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 using:

```
yapf 0.28.0
```

I have a dictionary that looks like this

```
query = {
'start': '1m-ago',
'queries': [
{
'metric': 'value.%d' % variable_id,
'aggregator': 'sum',
'downsample': '1d-avg',
'filters': [
{
'tagk': 'valid_id',
'filter': valid_id,
'type': 'literal_or',
'groupBy': False,
},
],
'rate': True,
'rateOptions': {
'counter': 'true',
'resetValue': 1000000000000
}
},
]
}
```

When I run yapf, I get a reformated dictionary that looks like this:

```
query = {
'start':
'1m-ago',
'queries': [
{
'metric':
'value.%d' % variable_id,
'aggregator':
'sum',
'downsample':
'1d-avg',
'filters': [
{
'tagk': 'valid_id',
'filter': valid_id,
'type': 'literal_or',
'groupBy': False,
},
],
'rate':
True,
'rateOptions': {
'counter': 'true',
'resetValue': 1000000000000
}
},
]
}
```

---

Why are some of my key/values being separated into two lines? Not all of them are separated and the ones that are, are some of the shorter lines.

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.