Skip to content

wrap_long_dict_values_in_parens can remove parentheses #4158

@JelleZijlstra

Description

@JelleZijlstra

Given this input:

x = {
    "xx_xxxxx_xxxxxxxxxx_xxxxxxxxx_xx": (
        "xx:xxxxxxxxxxxxxxxxx_xxxxx_xxxxxxx_xxxxxxxxxxx{xx}xxx_xxxxx_xxxxxxxxx_xxxxxxxxxxxx_xxxx"
    ),
}

The current draft new stable style outputs:

x = {
    "xx_xxxxx_xxxxxxxxxx_xxxxxxxxx_xx": "xx:xxxxxxxxxxxxxxxxx_xxxxx_xxxxxxx_xxxxxxxxxxx{xx}xxx_xxxxx_xxxxxxxxx_xxxxxxxxxxxx_xxxx",
}

This is because the string is long enough that it doesn't fit within the line length even if it's wrapped in parentheses.

However, the new style feels worse: it's over the line length either way, but it's a lot more over the line length in the new formatting.

The new style is consistent with our formatting in a few other cases, however. For example, we also remove the parentheses in:

xx_xxxxx_xxxxxxxxxx_xxxxxxxxx_xx = (
    xx_xxxxxxxxxxxxxxxxx_xxxxx_xxxxxxx_xxxxxxxxxxx_xx_xxx_xxxxx_xxxxxxxxx_xxxxxxxxxxxxxxxx
)

Is this bad enough to justify removing wrap_long_dict_values_in_parens from the new stable style? I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions