yapf: Options for preferring hanging indents with one item per line when formating lists
I would like to add options/code so that yapf can be configured to prefer outputting something like
MyLongNamedTuple = (
something.somethingelse,
something.somethingelse,
foo=(
bar.somethingelse,
something.asdfas,
),
)
over
MyLongNamedTuple = ( something.somethingelse,
something.somethingelse, foo=( bar.somethingelse,
something.asdfas),)
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 15
- Comments: 15 (8 by maintainers)
Any news regarding this feature? We are heavy user of vertical lists and it would be a much appreciated option to have.
Probably the best thing that can be done here is to use the heuristic that if the list ends in a comma then we will try to place them on individual lines. Otherwise, we will do “bin packing” on the items in the list.
as opposed to:
I feel like a list should read EITHER left to right OR Up to down but not both, and I think its worth the trade off in vertical space. Of course anything that can fit on a single reasonable line, should be left on a single line. For example if the variables in
fooin the above example wherebarandasdfthen even on the vertically stacked example i would want foo to be formatted asnot
Not everyone would agree with keeping lists 1 dimentional, so I would want this to be tune-able in style.
👍
I would love a configuration option to make comma-separated things always be either