google / google/yapf

let the author force breaks in a list using trailing comments

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

Description

This works in clang-format-- the empty comments force the list to be broken as shown:
```
int mymatrix[] = {
1, 2, 3, //
4, 5, 6, //
7, 8, 9 //
};
```
(clang-format aligns the comment markers, so there are indeed 3 spaces after the '9')

In yapf, attempting the same thing causes the whole list to switch to one-element-per-line formatting. Here's another use case, in python, as I'd expect it to stay formatted after yapf:
```
flags = [
'--flag1', val1, #
'--flag2', val2, #
]
```

Current behavior (undesirable, since it's harder to scan and to comment out key-val pairs atomically):
```
flags = [
'--flag1',
val1, #
'--flag2',
val2, #
]
```

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.