Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JelleZijlstra opened this issue Dec 10, 2022 · 1 comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. C: unstable formatting Formatting changed on the second pass F: parentheses Too many parentheses, not enough parentheses, and so on. F: strings Related to our handling of strings T: bug Something isn't working

Comments

@JelleZijlstra
Copy link
Collaborator

JelleZijlstra commented Dec 10, 2022

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.

@JelleZijlstra JelleZijlstra added T: bug Something isn't working C: unstable formatting Formatting changed on the second pass F: parentheses Too many parentheses, not enough parentheses, and so on. labels Dec 10, 2022
@JelleZijlstra
Copy link
Collaborator Author

Similar case that crashes up to length 8:

l3 = [
    "I have",
    "trailing comma",
    "so I should be braked",
]

@JelleZijlstra JelleZijlstra added the C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. label Dec 19, 2022
@hauntsaninja hauntsaninja added the F: strings Related to our handling of strings label Sep 3, 2023
@JelleZijlstra JelleZijlstra changed the title Instability with line length = 8 and parenthesized string string_processing: Instability with line length = 8 and parenthesized string Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. C: unstable formatting Formatting changed on the second pass F: parentheses Too many parentheses, not enough parentheses, and so on. F: strings Related to our handling of strings T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants