如何配置 YAPF 以对长参数列表使用悬挂缩进

How to configure YAPF to use hanging indentation for long argument lists

我使用 yapf 自动格式化我的 python 代码。总的来说我对它很满意,但是有一个样式约定我不知道如何配置。当一对括号内有一长串参数,超出最大值 column_limit(例如 80)时,我希望将它们分成单独的行,但尽可能保留左括号的缩进.例如:

def func(argument1, argument2, argument3, argument4, argument5, argument6, argument7):
    pass

应该变成

def func(argument1, 
         argument2, 
         argument3,
         argument4,
         argument5,
         argument6,
         argument7):
    pass

但我只能做到:

def func(
    argument1, 
    argument2, 
    argument3,
    argument4,
    argument5,
    argument6,
    argument7):
    pass

有人知道我想要的东西是否可行吗?怎么样?

检查这个:

SPLIT_BEFORE_FIRST_ARGUMENT
If an argument / parameter list is going to be split, then split before the first argument.

yapf 0.16.2: Formatting style