flake8-implicit-str-concat

January 7, 2026 · View on GitHub

PyPI version Supported Python versions PyPI downloads GitHub Actions status Codecov Licence Code style: Black Tidelift

This is a plugin for the Python code-checking tool Flake8 to encourage correct string literal concatenation.

It looks for style problems like implicitly concatenated string literals on the same line (which can be introduced by the code-formatting tool Black), or unnecessary plus operators for explicit string literal concatenation.

Install

pip install flake8-implicit-str-concat

Example

$ cat example.py
s = ('111111111111111111111'
     '222222222222222222222')
$ black example.py
reformatted example.py
All done! ✨ 🍰 ✨
1 file reformatted.
$ cat example.py
s = "111111111111111111111" "222222222222222222222"
$ flake8 example.py
example.py:1:28: ISC001 implicitly concatenated string literals on one line
$ edit example.py # Remove the " " and save
$ cat example.py
s = "111111111111111111111222222222222222222222"
$ black example.py
All done! ✨ 🍰 ✨
1 file left unchanged.
$ flake8 example.py
$

Violation codes

The plugin uses the prefix ISC, short for Implicit String Concatenation.

CodeDescription
ISC001implicitly concatenated string literals on one line
ISC002implicitly concatenated string literals over continuation line
ISC003explicitly concatenated string should be implicitly concatenated
ISC004unparenthesized implicit string concatenation in collection

ISC004

Checks for implicitly concatenated strings inside list, tuple, and set literals.

In collection literals, implicit string concatenation is often the result of a missing comma between elements, which can silently merge items together.

# Bad
facts = (
    "Lobsters have blue blood.",
    "The liver is the only human organ that can fully regenerate itself.",
    "Clarinets are made almost entirely out of wood from the mpingo tree."
    "In 1971, astronaut Alan Shepard played golf on the moon.",
)

# Good
facts = (
    "Lobsters have blue blood.",
    "The liver is the only human organ that can fully regenerate itself.",
    "Clarinets are made almost entirely out of wood from the mpingo tree.",
    "In 1971, astronaut Alan Shepard played golf on the moon.",
)

If the concatenation is intentional, wrap it in parentheses to make it explicit:

# Good
facts = (
    "Lobsters have blue blood.",
    "The liver is the only human organ that can fully regenerate itself.",
    (
        "Clarinets are made almost entirely out of wood from the mpingo tree."
        "In 1971, astronaut Alan Shepard played golf on the moon."
    ),
)

Release notes

You can find the release notes on the releases page.