Skip to content

Don't break a line if it's too long because of comments #3329

@josephernest

Description

@josephernest

A long line is split into multiple lines if it exceeds the black_line_length setting.
How to not take the comments into consideration to compute the line length?

Example:

# this one should still be broken into multiple lines
long_function(param_1="this is a long line, longer than 80 characters", param_2="this is a long line, longer than 80 characters")  # comment here

# this one SHOULD NOT be broken because the code is smaller than 80 char
short_function(param_1="foo", param_2="bar")  # long comment here, which finally makes the line longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters

Is there already a setting for this?

Currently the second example gives:

short_function(
    param_1="foo", param_2="bar"
)  # long comment here, which finally makes the line longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters longer than 200 characters

and I'd prefer to not break the line at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: commentsThe syntactic kind. Not in the language grammar, always on our minds. Best bugs.F: linebreakHow should we split up lines?T: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions