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

[pydoclint] Consider DOC201 satisfied if docstring begins with "Returns" #12675

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

augustelalande
Copy link
Contributor

Summary

Resolves #12636

Consider docstrings which begin with the word "Returns" as having satisfactorily documented they're returns. For example

def f():
    """Returns 1."""
    return 1

is valid.

Test Plan

Added example to test fixture.

@charliermarsh charliermarsh added docstring Related to docstring linting or formatting preview Related to preview mode features labels Aug 5, 2024
Copy link
Contributor

github-actions bot commented Aug 5, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh
Copy link
Member

Should this only be applied to single-line docstrings?

@augustelalande
Copy link
Contributor Author

The google document is not specific. I leave it up to you.

@augustelalande
Copy link
Contributor Author

Also I guess this should also apply to yield. I'll add that.

@augustelalande
Copy link
Contributor Author

augustelalande commented Aug 5, 2024

I think technically

and the opening sentence is sufficient to describe the return value.

implies that there may be more than one sentence.

@dhruvmanila dhruvmanila self-assigned this Aug 6, 2024
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added test cases for multiline docstring for both "Returns" and "Yields".

@dhruvmanila dhruvmanila enabled auto-merge (squash) August 6, 2024 06:30
@dhruvmanila dhruvmanila merged commit f0318ff into astral-sh:main Aug 6, 2024
19 checks passed
@augustelalande augustelalande deleted the doc201 branch August 6, 2024 17:30
dylwil3 pushed a commit to dylwil3/ruff that referenced this pull request Aug 7, 2024
…eturns" (astral-sh#12675)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

Resolves astral-sh#12636

Consider docstrings which begin with the word "Returns" as having
satisfactorily documented they're returns. For example
```python
def f():
    """Returns 1."""
    return 1
```
is valid.

## Test Plan

Added example to test fixture.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting preview Related to preview mode features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC201 requires a returns section even when not required by the Google style guide
3 participants