Skip to content

multi-line-implicit-string-concatenation (ISC002)

Derived from the flake8-implicit-str-concat linter.

What it does

Checks for implicitly concatenated strings that span multiple lines.

Why is this bad?

For string literals that wrap across multiple lines, PEP 8 recommends the use of implicit string concatenation within parentheses instead of using a backslash for line continuation, as the former is more readable than the latter.

By default, this rule will only trigger if the string literal is concatenated via a backslash. To disallow implicit string concatenation altogether, set the lint.flake8-implicit-str-concat.allow-multiline option to false.

Example

z = "The quick brown fox jumps over the lazy "\
    "dog."

Use instead:

z = (
    "The quick brown fox jumps over the lazy "
    "dog."
)

Options

Formatter compatibility

Using this rule with allow-multiline = false can be incompatible with the formatter because the formatter can introduce new multi-line implicitly concatenated strings. We recommend to either:

  • Enable ISC001 to disallow all implicit concatenated strings
  • Setting allow-multiline = true