Describe the bug
Removal of new line in docstrings can violate the line length constraint if the last line is within two characters of the max line length value.
To Reproduce Steps to reproduce the behavior:
Run black on the following code with the default line-length constraint of 88 characters.
def f():
"""89 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678
"""
pass
Expected behavior
No reformatting is performed.
Actual behavior
The code is reformatted as shown below, which violates the max line length constraint.
def f():
"""89 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678"""
pass
In a CI setup with Flake8 running after black, Flake8 throws the following error:
test.py:2:89: E501 line too long (91 > 88 characters)
Environment (please complete the following information):
- All versions of black from 20.8b0 up to 21.5b1 as well as main (d3670d9).
- Reproduced on Windows 10 & Ubuntu 18.04/20.04, Python 3.7 & 3.8
Does this bug also happen on main?
Yes
Additional context
black 19.10b0 does not have this behavior.
This was reported in #1635 (comment).
Describe the bug
Removal of new line in docstrings can violate the line length constraint if the last line is within two characters of the max line length value.
To Reproduce Steps to reproduce the behavior:
Run black on the following code with the default line-length constraint of 88 characters.
Expected behavior
No reformatting is performed.
Actual behavior
The code is reformatted as shown below, which violates the max line length constraint.
In a CI setup with Flake8 running after black, Flake8 throws the following error:
Environment (please complete the following information):
Does this bug also happen on main?
Yes
Additional context
black 19.10b0 does not have this behavior.
This was reported in #1635 (comment).