-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: crashBlack is crashingBlack is crashingC: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsRelated to our handling of stringsT: bugSomething isn't workingSomething isn't working
Description
Describe the bug
If you:
- have string processing enabled
- have a line that has a string literal exceeding line-length, followed by a trailing comma (to make it a one-item tuple)
- the line is NOT assigned to a variable
...then black will error.
To Reproduce
Run this code in bash:
echo '"A long string literal that is not assigned to a variable, exceeds line length when string-processing is enabled, and has a trailing comma (to make it a one-item tuple)",' | black --preview --enable-unstable-feature=string_processing -...or, alternatively, save this to a file called string_processing_trailing_comma_error.py:
"A long string literal that is not assigned to a variable, exceeds line length when string-processing is enabled, and has a trailing comma (to make it a one-item tuple)",...and then run:
black --preview --enable-unstable-feature=string_processing string_processing_trailing_comma_error.pyThe resulting error is:
error: cannot format -: INTERNAL ERROR: Black 25.12.1.dev6+gc3cc5a95d on Python (CPython) 3.10.14 produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_jxevpxw3.log
Oh no! 💥 💔 💥
1 file failed to reformat.
Expected behavior
The string should be split up, without generating an error.
Environment
- Black's version: main (c3cc5a9) and 26.1a1
- OS and Python version: ubuntu-22.04.5 LTS, python-3.10.4 and python-3.12.11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C: crashBlack is crashingBlack is crashingC: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsRelated to our handling of stringsT: bugSomething isn't workingSomething isn't working