Skip to content

Formatter incompatibility: extra parentheses around binary expression #7431

@charliermarsh

Description

@charliermarsh

Given:

if True:
    if True:
        if True:
            if True:
                msg += " " + _(
                    "Since the role is not mentionable, it will be momentarily made mentionable "
                    "when announcing a streamalert. Please make sure I have the correct "
                    "permissions to manage this role, or else members of this role won't receive "
                    "a notification."
                )

Ruff formats as:

if True:
    if True:
        if True:
            if True:
                msg += (
                    " "
                    + _(
                        "Since the role is not mentionable, it will be momentarily made mentionable "
                        "when announcing a streamalert. Please make sure I have the correct "
                        "permissions to manage this role, or else members of this role won't receive "
                        "a notification."
                    )
                )

Black formats as:

if True:
    if True:
        if True:
            if True:
                msg += " " + _(
                    "Since the role is not mentionable, it will be momentarily made mentionable "
                    "when announcing a streamalert. Please make sure I have the correct "
                    "permissions to manage this role, or else members of this role won't receive "
                    "a notification."
                )

(Apologies for all the if True:, easiest way to preserve the indentation depth.)

Sourced from #7394.

Other examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterneeds-decisionAwaiting a decision from a maintainer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions