Skip to content
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

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

Open
Zac-HD opened this issue Aug 20, 2024 · 1 comment
Labels
rule Implementing or modifying a lint rule

Comments

@Zac-HD
Copy link

Zac-HD commented Aug 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

2 participants