Formatter: Option for compact wrapping comma-separated constructs #28098
danransdorf
started this conversation in
Ideas
Replies: 1 comment
|
Some previous discussions |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Hello, would you consider an option to keep multiple items on the same line when they fit?
For example, Ruff currently formats this as:
I’d prefer something like:
Basically packing items onto a continuation line until it hits the configured
line-length. Similar behavior exists in clang-format as parameter “bin packing”, and similar style is common in F#. YAPF can do this as well, and it’s the main thing keeping me from fully switching to Ruff.I’m not suggesting changing Ruff’s default formatting here, I’d be happy for this to be an opt-in formatter option.
I know Ruff intentionally keeps formatter options limited, so I’m mostly wondering if this is something you’d consider at all. Otherwise I may just keep a small fork.
I’d be happy to try implementing this option, if it fits Ruff’s direction.
Similar discussions
The closest discussions I found mostly touch on related
skip-magic-trailing-commaoption.Examples (for more illustration)
Calls with several kwargs
This becomes noticeable with calls that have bunch of short kwargs:
I'd prefer:
Database calls / tuples
Same thing with database calls with tuples:
I'd prefer:
All reactions