Skip to content

Formatter: Allow comments between and/or and the right hand side #6062

@konstin

Description

@konstin

The following input is stable with black ...

if (
    a
    # own line comment between left hand side and `and`
    and
    # own line comment between `and` and right hand side
    b
):
    pass

... but we move the second own line comment before the and:

if (
    a
    # own line comment between left hand side and `and`
    # own line comment between `and` and right hand side
    and b
):
    pass

The behavior is the same with or, but + works, i.e. other binary expressions work but not boolean expressions.

Metadata

Metadata

Assignees

Labels

formatterRelated to the formatter

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions