ALL-STRI0001 · fragmented_multiline_literal
Count multiline values assembled from adjacent literal fragments.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Inspect folded string constants whose runtime value contains at least one newline. Count the
lexical string tokens that Python implicitly concatenates and report the expression when the
count reaches minimum_fragments. A triple-quoted or escaped single literal is one token and
is not reported. Adjacent fragments used only to wrap one runtime line are also excluded.
Evidence
Section titled “Evidence”Every finding gives the complete expression range and its literal-fragment count. The result value is the number of reported expressions.
Exceptions
Section titled “Exceptions”Keep fragments when exact indentation, escaping, translation extraction, generated text, or
a deliberate trailing-newline policy is clearer than one literal. The safe fix chooses the
triple quote absent from the value and leaves values containing backslashes or both quote forms
for review. Ruff ISC003 separately prefers implicit adjacency over an explicit + between
literals.
Examples
Section titled “Examples”("first line\\n" "second line\\n") is reported as a two-fragment multiline value. One
triple-quoted literal containing both lines is accepted. ("one long " "runtime line") is
accepted because changing it to a multiline literal would change its value.
References
Section titled “References”- Cites “The Python Language Reference”, string literal concatenation. Open reference
- Generalizes Ruff ISC003 explicit-string-concatenation. Open reference