-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: docstringsHow we format docstringsHow we format docstringsF: linebreakHow should we split up lines?How should we split up lines?T: bugSomething isn't workingSomething isn't working
Description
Describe the bug
Single-line docstrings that are longer than the line length have the final three " moved to a new line.
To Reproduce
For example, take this code:
from typing import Optional
# leaves this the same
def large_image_url(self) -> Optional[str]:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
pass
# leaves this the same too
def large_image_url(self) -> Optional[str]:
"""
Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
pass
# depending on the length of the docstring, this one *may* be left as-is
def large_image_url(self) -> Optional[str]:
"""
Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable."""
pass
# but this one is modified
def large_image_url(self) -> Optional[str]:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable."""
passAnd run it with these arguments:
$ black file.py --previewWe get this format:
from typing import Optional
# leaves this the same
def large_image_url(self) -> Optional[str]:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
pass
# leaves this the same too
def large_image_url(self) -> Optional[str]:
"""
Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
pass
# this one is also left as-is
def large_image_url(self) -> Optional[str]:
"""
Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
pass
# but this one is modified
def large_image_url(self) -> Optional[str]:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable.
"""
passExpected behavior
Single line docstrings are left alone. I understand what this change is supposed to do, and on already multiline docstrings this wouldn't be an issue (although it would be nice for the docstring formatter to be entirely consistent among all docstrings instead of having different behavior for the line length but i digress).
Environment
- Black's version: 22.10.0
- OS and Python version: Python 3.11.0rc2, on linux, but i can recreate with python 3.8 too
Additional Comments
This seems like a regression from #3044
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F: docstringsHow we format docstringsHow we format docstringsF: linebreakHow should we split up lines?How should we split up lines?T: bugSomething isn't workingSomething isn't working