astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.2k stars 1.04k forks source link

pydocstyle: args/returns/raises should be sentences #10979

Open adamjstewart opened 5 months ago

adamjstewart commented 5 months ago

Feature Request

I would like to propose a new pydocstyle rule that converts:

"""My fancy function.

Args:
    foo: an arg

Returns:
    an output
"""

to:

"""My fancy function.

Args:
    foo: An arg.

Returns:
    An output.
"""

Rationale

All args/returns/raises/etc. in the Google style guide are sentences (they start with a capital letter and end with a period), but the style guide does not explicitly say whether or not this is required. Whether or not we include it in the "google" convention (this would be a change in behavior from pydocstyle) is less important to me. I just want an easy way to make all my docstrings consistent.

Additional Information

This was briefly discussed in https://github.com/PyCQA/pydocstyle/issues/547 but a final decision was never reached.

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!

RubenVanEldik commented 4 weeks ago

I ran into inconsistent formatting on this topic in our codebase as well! I think it would make sense to add this rule, even though Pydocstyle itself has never implemented it. Could one of the maintainers let us know if this is something that they agree with, or do we want Ruff to keep following Pydocstyle and not expanding it?