如何阻止 Black 在函数调用 args 中删除新行?

问题描述

我想记录一个外部函数

strange_function(
    # Comments about what this argument does
    param_1=True,# Comments about what this argument does
    param_2=False,)

黑色将其重新格式化为:

strange_function(
    # Comments about what this argument does
    param_1=True,)

想要 param_1param_2间的新行,因为这样注释更易读。但黑色消除了这一点。它如何阻止它这样做?

解决方法

你不能。

黑色非常无情,只给你一个旋钮来转动:每行允许多少个字符。