Skip to content

string_processing: Instability with line length = 8 and parenthesized string #3424

@JelleZijlstra

Description

@JelleZijlstra

Code:

print(
    "Long lines with inline comments which are apart of (and not the only member",
    "Arg #2",
    "Arg #3",
)

On black 22.12.0:

% black --preview --diff tests/data/miscellaneous/long_strings_flag_disabled.py -l 8
error: cannot format tests/data/miscellaneous/long_strings_flag_disabled.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_1d6da39c.log

Oh no! 💥 💔 💥
1 file would fail to reformat.

I assume this only happens at line-length <= 8 because then the indentation by itself is enough to fill up the line. It probably also reproes with a reasonable line length if you indent the whole thing by 20 or so levels, but I haven't tried.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.C: unstable formattingFormatting changed on the second passF: parenthesesToo many parentheses, not enough parentheses, and so on.F: stringsRelated to our handling of stringsT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions