Skip to content

implicit-str-concat: allow wrapping implicitly concatenated strings in parenthesis. #8552

@yilei

Description

@yilei

Current problem

Internally, we have enabled the --check-str-concat-over-line-jumps option for implicit-str-concat. But we also allow wrapping implicitly concatenated strings in parenthesis. This is done by our internal patch to Pylint ~3 years ago.

Example code:

a = [
    "aa bb"
    "cc dd",
]

It raises implicit-str-concat on the "aa bb" line, that's good to catch bugs of missing commas.

But for long strings that must be put on multiple lines, currently you need to use explicit str concatenations:

a = [
    "aaaaaaaa aaaaaaaa "
    + "aaaaaaaa aaaaaaaa ",
]

We think it should also be fine to use implicit str concatenations BUT wrapped inside parenthesis:

a = [
    ("aaaaaaaa aaaaaaaa "
     "aaaaaaaa aaaaaaaa "),
]

Desired solution

Introduce an opt-in option allow-parenthesized-str-concat. When enabled, allow the use of parenthesis.

Additional context

WDYT? If you agree, I'll send out our patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions