Skip to content

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

Merged
dhruvmanila merged 5 commits intoastral-sh:mainfrom
augustelalande:doc201
Aug 6, 2024
Merged

[pydoclint] Consider DOC201 satisfied if docstring begins with "Returns"#12675
dhruvmanila merged 5 commits intoastral-sh:mainfrom
augustelalande:doc201

Conversation

@augustelalande
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown
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
Copy Markdown
Member

Should this only be applied to single-line docstrings?

@augustelalande
Copy link
Copy Markdown
Contributor Author

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

@augustelalande
Copy link
Copy Markdown
Contributor Author

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

Comment thread crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs
@augustelalande
Copy link
Copy Markdown
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
Copy Markdown
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
@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