PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
530 stars 61 forks source link

Bug: not splitting two sentence summary into description #275

Closed jamesbraza closed 2 months ago

jamesbraza commented 8 months ago

Please see the below Python snippet, I am using Python 3.11 with docformatter==1.7.5:

# a.py

def foo() -> None:
    """I am a first sentence this long. I am another sentence that I would like to be in summary."""

Running docformatter --black --close-quotes-on-newline a.py formats it to:

# a.py

def foo() -> None:
    """
    I am a first sentence this long.

    I am another sentence that I would like to be in summary.
    """

I understand why the summary line is being split, because it violates the 88-char summary wrap length. However, I would like docformatter to avoid splitting the summary into a description like so:

# a.py

def foo() -> None:
    """
    I am a first sentence this long. I am another sentence that I would like to be in
    summary.
    """

I think what this warrants is:

weibullguy commented 2 months ago

Per PEP-257:

Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description.

And and one-line docstring, per PEP-257:

The docstring is a phrase ending in a period. It prescribes the function or method’s effect as a command (“Do this”, “Return that”), not as a description; e.g. don’t write “Returns the pathname …”.

The example you provide is a multi-line docstring per PEP-257 and is being handled appropriately.