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

Prefer splitting right hand side of assignment first: Unnecessary parentheses #9112

Closed
MichaReiser opened this issue Dec 13, 2023 · 0 comments · Fixed by #9209
Closed

Prefer splitting right hand side of assignment first: Unnecessary parentheses #9112

MichaReiser opened this issue Dec 13, 2023 · 0 comments · Fixed by #9209
Labels
formatter Related to the formatter preview Related to preview mode features

Comments

@MichaReiser
Copy link
Member

Ruff introduces unnecessary parentheses around values when the target doesn't end with a parenthesized expression, but only contains one:

a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[xxxxx].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = ccccccccccccccccccccccccccccccccccc["aaaaaaa"]

a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[xxxxx].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = ccccccccccccccccccccccccccccccccccc["aaaaaaa"]

Black

a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
    xxxxx
].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = (
    ccccccccccccccccccccccccccccccccccc["aaaaaaa"]
)

a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
    xxxxx
].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = ccccccccccccccccccccccccccccccccccc[
    "aaaaaaa"
]

Ruff

a = (
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
        xxxxx
    ].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
) = ccccccccccccccccccccccccccccccccccc["aaaaaaa"]

a = (
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
        xxxxx
    ].bbvbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
) = ccccccccccccccccccccccccccccccccccc["aaaaaaa"]

Ruff's output is more noisy because of the extra parentheses.

@MichaReiser MichaReiser added formatter Related to the formatter preview Related to preview mode features labels Dec 13, 2023
@MichaReiser MichaReiser added this to the Formatter: Stable milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter preview Related to preview mode features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant