black
black copied to clipboard
string_processing: Instability with line length = 8 and parenthesized string
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.
Similar case that crashes up to length 8:
l3 = [
"I have",
"trailing comma",
"so I should be braked",
]