Skip to content

Add a new rule to warn on implicitly-concatenated strings separated by a comment #13014

@Zac-HD

Description

@Zac-HD

What's wrong with this code?

cmd = [
    "rsync",
    "-avz",  # archive mode, verbose, compress
    "-e",
    "ssh",
    "--exclude=.git"  # equivalent to ignore-vcs
    "--delete",
    "/root/code/api/",
    "user@remote:/app/"
    # Preserve symlinks as-is  (equivalent to --symlink-mode=posix-raw)
    "--links",
]
subprocess.run(cmd)

It's missing two commas! However, if you're generally OK with multi-line implicit concatenation (which I am), there's currently no way to get a warning for this case. I therefore propose adding a new rule, ISC004, which will warn if implicitly-concatenated strings are separated by a comment - which can be fixed by either adding an explicit + or moving the comment.

See also flake8-implicit-str-concat/flake8-implicit-str-concat#55. I would not add an autofix for this lint rule, as the intended semantics are ambiguous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing 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