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

Consider keeping the parens of implicitly concatenated strings when it's a argument of a function call #3260

Closed
yilei opened this issue Sep 6, 2022 · 2 comments
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. F: strings Related to our handling of strings T: style What do we want Blackened code to look like?

Comments

@yilei
Copy link
Contributor

yilei commented Sep 6, 2022

Describe the style change

Original code:

function_call(
    (
        " lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor"
        " incididunt ut labore et dolore magna aliqua Ut enim ad minim"
    ),
    " veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo",
)

Examples in the current Black preview style

black --preview removes the parens since they are "not necessary":

function_call(
    " lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor"
    " incididunt ut labore et dolore magna aliqua Ut enim ad minim",
    " veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo",
)

Desired style

Keep the parens:

function_call(
    (
        " lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor"
        " incididunt ut labore et dolore magna aliqua Ut enim ad minim"
    ),
    " veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo",
)

Additional context

Parens in this case can increase readability, Black can choose to NOT universally add parens for them (see #3162 (comment)). However, if the code explicitly adds parens to the implicitly concatenated strings, I suggest Black not removing them as the parens are indications of needing to wrap the string to increase readability.

This might be not necessary if Black chooses to use explicit str concatenations (#2553).

@yilei yilei added the T: style What do we want Blackened code to look like? label Sep 6, 2022
@yilei yilei changed the title Consider to not remove parens of implicitly concatenated strings when it's a argument of a function call Consider keeping the parens of implicitly concatenated strings when it's a argument of a function call Sep 7, 2022
@felix-hilden felix-hilden added F: parentheses Too many parentheses, not enough parentheses, and so on. F: strings Related to our handling of strings labels Sep 11, 2022
@felix-hilden
Copy link
Collaborator

I'd be open to keeping them, or even going all the way. But I understand that diffs getting larger is awkward.

@yilei
Copy link
Contributor Author

yilei commented Dec 15, 2022

This is obsoleted by #3292 (implemented in #3307).

@yilei yilei closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. F: strings Related to our handling of strings T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

3 participants