pylint icon indicating copy to clipboard operation
pylint copied to clipboard

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

Open jhbuhrman opened this issue 2 years ago • 3 comments

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 https://github.com/PyCQA/pylint/issues/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 avatar Dec 12 '22 22:12 jhbuhrman