Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydocstyle: undocumented returns #11435

Closed
adamjstewart opened this issue May 15, 2024 · 2 comments
Closed

pydocstyle: undocumented returns #11435

adamjstewart opened this issue May 15, 2024 · 2 comments

Comments

@adamjstewart
Copy link

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 PyCQA/pydocstyle#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!

@augustelalande
Copy link
Contributor

This could be part of #458 which hasn't been implemented yet

@dhruvmanila
Copy link
Member

Thank you for such a detailed issue! I'll merge this with #458, specifically DAR201 and DAR301 which covers return and yield respectively.

@dhruvmanila dhruvmanila closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants