0

I want to document an external function:

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

    # Comments about what this argument does
    param_2=False,
)

Black reformats it as:

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

I want the new line between param_1 and param_2 because comments are more readable that way. But black removes this. How do it stop it from doing so?

Rol
  • 501
  • 4
  • 13
  • Isn't the entire idea behind black that it's uncompromising and won't let you decide on fomratting etc? – tbjorch Feb 10 '21 at 09:57
  • It has some options. – Rol Feb 10 '21 at 09:57
  • 1
    When commenting arguments i would rather recommend using a multiline docstring instead of embedding it like that – tbjorch Feb 10 '21 at 09:59
  • Agreew with @tbjorch, this is quite unreadable. An interested reader of that function might be interested in the signature of the function. Seperate signature and documentation! For documentation of functions and its arguements see [Python Docstring Conventions](https://www.python.org/dev/peps/pep-0257/) – AnsFourtyTwo Feb 10 '21 at 10:28

1 Answers1

0

You cannot.

Black is very unforgiving, giving you only a single knob to turn: how many characters per line to allow.

syntonym
  • 7,134
  • 2
  • 32
  • 45