Black code formatter line length ignore comment included

Viewed 1968

So, it seems, that Black code formatter default line-length option also takes under consideration comments included in the line

For example

if some_very_long_variable_name_out_there_for_example is True: # just a random comment
    pass

Will produce in

if (
    some_very_long_variable_name_out_there_for_example is True
    ):  # just a random comment
    pass

, which is definitly correct in terms of black standard

However, the line if some_very_long_variable_name_out_there_for_example is True: is actually less than 88 symbols and I don't want my code to be kinda visually broken just because I added comment

Is there an option to disable such behaviour?

1 Answers

It's not really answering your question, but I guess you could get into a habit of writing in this form instead:

# just a random comment on the previous line
if some_very_long_variable_name_out_there_for_example is True:
    pass
Related