Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap_long_dict_values_in_parens can remove parentheses #4158

Open
JelleZijlstra opened this issue Jan 20, 2024 · 2 comments
Open

wrap_long_dict_values_in_parens can remove parentheses #4158

JelleZijlstra opened this issue Jan 20, 2024 · 2 comments
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working

Comments

@JelleZijlstra
Copy link
Collaborator

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.

@JelleZijlstra JelleZijlstra added T: bug Something isn't working C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. labels Jan 20, 2024
@hauntsaninja
Copy link
Collaborator

Re: removing from 2024 stable style, there's also #3452 (we've resolved #3758 and are likely to resolve #4129)

@RedGuy12
Copy link
Contributor

Interestingly enough, it looks like string_processing and wrap_long_dict_values_in_parens both individually trigger this behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants