Skip to content

Formatter: Trailing end of line comments in binary like expressions #7004

@MichaReiser

Description

@MichaReiser
# Input
if (
    (1 + 2) or # test
    (3 + 4) or # other
    (4 + 5) # more
): pass


if (
    (1 and 2) + # test
    (3 and 4) + # other
    (4 and 5) # more
): pass


if (
    (1 + 2) < # test
    (3 + 4) > # other
    (4 + 5) # more
): pass

# Output
if (
    (
        1 + 2  # test
    )
    or (
        3 + 4  # other
    )
    or (4 + 5)  # more
):
    pass


if (
    (
        1 and 2  # test
    )
    + (3 and 4)  # other
    + (4 and 5)  # more
):
    pass


if (
    (
        1 + 2  # test
    )
    < (
        3 + 4  # other
    )
    > (4 + 5)  # more
):
    pass

Expected
Ruff not to expand the parenthesized right sides.

Note: Prettier handles this correctly

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