PyCQA / docformatter

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

Do Not Remove Newline Following docstring in Stub Functions #154

Closed weibullguy closed 1 year ago

weibullguy commented 1 year ago

In functions and methods with only a docstring, it is stylistically considered redundant to include a pass statement. See the pylint issue requesting the Unnecessary pass warning. However, PEP257 states, "There’s no blank line either before or after the docstring." Thus, in the following code snippet, the newline before the second function will be removed by docformatter which causes pylint to raise the W0107 warning (see here).

def a_function():
    """Here we have a stub function that does ugatz."""

def b_function():
    """Here we have the next function separated from the first by a newline.

    We want the newline to remain in place, but currently docformatter
    removes it because it sees the def statement as the next line of code.
    """

Currently, including a pass statement in a_function will cause docformatter to retain the newline, However, docformatter should recognize a_function as a stub and retain the newline without the use of a pass statement.