Describe the bug
A Python file containing a single string assignment longer than the line length limit is not reformatted.
To Reproduce
Take long_line.py:
long = "This is a long line that is longer than 88 characters. I expect Black to shorten this line length."
Run Black:
$ black ./long_line.py
All done! ✨ 🍰 ✨
1 file left unchanged.
Expected behavior
I expect black to shorten the line length to less than the length limit. One possible solution is to break on the <line length limit minus 1> character and parenthesize if it is not already inside parentheses:
long = (
"This is a long line that is longer than 88 characters. I expect Black to shorten "
"this line length."
)
Environment (please complete the following information):
$ black --version
black, version 20.8b1
OS: macOS Catalina 10.15.6
$ python --version
Python 3.8.5
Does this bug also happen on master?
Yes
Additional context
None
This is currently implemented under the hidden --experimental-string-processing flag, which we'll hopefully be able to enable soon.
Confirmed that this works as expected.
$ black ./long_line.py --experimental-string-processing
reformatted long_line.py
All done! ✨ 🍰 ✨
1 file reformatted.
long = (
"This is a long line that is longer than 88 characters. I expect Black to shorten"
" this line length."
)
Most helpful comment
This is currently implemented under the hidden
--experimental-string-processingflag, which we'll hopefully be able to enable soon.