Describe the bug When there's a docstring that's near the max line length with the """ on the next line, the new version of Black moves the """ to the first line, making the line too long.
To Reproduce Steps to reproduce the behavior:
Create a file with this content:
def my_func():
"""Remove punctuation and return cleaned string plus its length in tokens.
"""
pass
Reformat it
Note that it now has the docstring on one line and that that line has 82 chars:
def my_func():
"""Remove punctuation and return cleaned string plus its length in tokens."""
pass
Expected behavior
The docstring shouldn't get wrapped.
Environment (please complete the following information):
Version: [e.g. master] 20.8b1
OS and Python version:
Linux/Python 3.8.2
Does this bug also happen on master? To answer this, you have two options:
Hello @mlissner.
The default line length limit is 88 so I don't see what is wrong with Black wrapping the docstring as it still fits. Do you happen to have a pyproject.toml configuration file?
Sorry, should have mentioned we have it set to 79. I think this link has that config and you can still see it:
Okay, now this bug makes sense. Thanks for clarifying!
Git bisect points to a4c11a7 as the first bad commit, from "Re-indent the contents of docstrings" (#1053).
Good catch, we'll fix it in the next release which is planned for the week of Sept 28th (likely Oct 1). If this is a deal breaker for you, I suggest pinning to 19.10b0 in the mean time.
Hi, is there an ETA for this?
Most helpful comment
Good catch, we'll fix it in the next release which is planned for the week of Sept 28th (likely Oct 1). If this is a deal breaker for you, I suggest pinning to 19.10b0 in the mean time.