-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: stringsRelated to our handling of stringsRelated to our handling of stringsR: duplicateThis issue or pull request already existsThis issue or pull request already existsT: bugSomething isn't workingSomething isn't working
Description
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
"""
passExpected 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"""
passIn 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).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F: stringsRelated to our handling of stringsRelated to our handling of stringsR: duplicateThis issue or pull request already existsThis issue or pull request already existsT: bugSomething isn't workingSomething isn't working