Skip to content

Detect and prevent implicit string concatenations e.g. lists #13031

@KennethEnevoldsen

Description

@KennethEnevoldsen

A typical error I (and colleagues) run into is as follows:

mylist = ["a", "b" "c"] 
# results in:
mylist # ['a', 'bc']

# as opposed to the intended ["a", "b", "c"] 

While this pattern is often well known, this pattern can often lead to unintended side effects, which are hard to track and detect.

This suggestion is in line with pep3126 (which was rejected due to "the feature to be removed isn’t all that harmful").

I have searched existing ruff rules and only found the ISC rules, which do not cover this pattern. The proposed pattern is in line with some of the ISC rules (ISC001), while I would say it disagrees with (ISC003)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions