ruff icon indicating copy to clipboard operation
ruff copied to clipboard

pydocstyle: undocumented returns

Open adamjstewart opened this issue 9 months ago • 1 comments

Feature Request

I would like to propose a new pydocstyle rule that checks for undocumented return values.

Implementation

Specifically, ruff would check to see if a function is missing one of the following sections (assuming Google-style):

  • Returns: for normal functions
  • Yields: for generators

According to the Google Python Style Guide:

If the function only returns None, this section is not required. It may also be omitted if the docstring starts with “Return”, “Returns”, “Yield”, or “Yields”

In the case where the return type of the function is not None and none of the above criteria are met, a rule violation should be issued.

Rationale

The Google Python Style Guide and the NumPy Style Guide both explicitly require return values to be documented.

Additional Information

The only related feature request I could find in the pydocstyle repo is https://github.com/PyCQA/pydocstyle/issues/479. However, their criteria for whether or not a return value should be documented is whether or not an Args: section is present. I think checking the return type is much more reliable though.

If this is something ruff would be willing to accept, I can try my hand at following https://docs.astral.sh/ruff/contributing/#example-adding-a-new-lint-rule and submit a PR!

adamjstewart avatar May 15 '24 18:05 adamjstewart