yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Split arguments into separate lines if they're multiline

Open WhyNotHugo opened this issue 8 years ago • 4 comments

I've some function calls where arguments don't fit a single line:

  some_function(some_value, some_value, some_value, some_value, some_value,
              some_value)

For cases such as these, I'd prefer to always split each argument into a separate line (I feel that this is extremely common):

some_function(
    some_value,
    some_value,
    some_value,
    some_value,
    some_value,
    some_value)

This is currently not possible. The closest thing is SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED, but that only applies if there's a trailing comma. In my case, I don't want to depend on the comma, but rather of whether the arguments fit in a single line or not.

WhyNotHugo avatar Oct 01 '17 06:10 WhyNotHugo

I have the exact same problem. I get this code:

some.Object.whatever.function(
    some_value, some_value, some_value
)

Which is annoying. If YAPF is going to split that, I want it to always split into multiple lines.

skorokithakis avatar Oct 30 '17 16:10 skorokithakis

Fix coming in https://github.com/google/yapf/pull/550!

decentral1se avatar May 12 '18 21:05 decentral1se

@decentral1se I think that update does not apply to function calls like in the main issue? I'm experiencing the same problem.

corynezin avatar Sep 18 '19 21:09 corynezin

Agreed, SPLIT_ALL_COMMA_SEPARATED_VALUES forces always splitting on args, not only if already being split from another rule.

D-Pow avatar Oct 03 '21 02:10 D-Pow