Skip to content

Only warn for implicit string concatenation when parts are _not_ surrounded by a set of parentheses #7929

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

Open
jhbuhrman opened this issue Dec 12, 2022 · 3 comments
Labels
Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.

Comments

@jhbuhrman
Copy link

Current problem

As I would like to be warned for an omission like the following: ...

COLORS = [
    "red"
    "yellow",
    "blue",
]

(note the missing comma after "red"), I've activated pylint's check-str-concat-over-line-jumps check.

In order to prevent a line-too-long warning for the following code fragment:

    reference = "https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#string-checker"

I could break down such a fragment into something like:

    reference = "https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html" \
                "#string-checker"

but my preference would be a format, equal to how the black formatter would reformat the example right above:

    reference = (
        "https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html"
        "#string-checker"
    )

However, because I activated the check-str-concat-over-line-jumps check, I get a (false?) positive check on the fragment above.

What can be done so that I will be warned for the COLORS example above, but not for the intentional string concatenation?

Desired solution

My request is that pylint only warns about implicit string concatenation in case the parts of the concatenations are not collected in a set of parentheses.

Whether that "feature" should be accompanied by a configuration item or not is something I cannot judge about.

Additional context

Have a look at #6663 as well, as I think that simply adding parentheses to the string concatenation in that particular example would be a perfectly acceptable workaround for me.

@jhbuhrman jhbuhrman added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 12, 2022
@DanielNoord
Copy link
Collaborator

I guess we should be able to check whether the line jump is within a single tuple/parenthesis? That should work right?

@jhbuhrman
Copy link
Author

Line jump or line jumps, yes. And indeed when directly between a pair of parentheses. I would certainly not use the word "tuple" in this context.

And I guess you noticed already that I wouldn't mind at all when that same rule would apply to string concatenation of parts on the same line as well.

Thanks for your reply.

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc. and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 13, 2022
@Timmmm
Copy link

Timmmm commented May 6, 2025

I think this was implemented in 81917bc.

But really you should just use +. Implicit string concatenation is a misfeature.

reference = (
    "https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html" +
    "#string-checker"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.
Projects
None yet
Development

No branches or pull requests

4 participants