Skip to content

Conversation

@NMertsch
Copy link

@NMertsch NMertsch commented Jan 19, 2023

What's new

Implementation details

  • Help messages were copied from pydocstyle.
  • The pydocstyle version is checked, the options are only added to the CLI and passed to pydocstyle if the version supports it (previously: try-catch construct to check if --ignore-noqa from pydocstyle 6.0.0 is available).

How to test

Example file code.py:

"""This is my module."""
from functools import cached_property


class MyClass:
    """This is my class."""

    def __init__(self):
        # missing docstring, raises D107 unless '--ignore-self-only-init' is set
        pass

    @property
    def my_property(self) -> str:
        """This is my property."""
        # non-imperative docstring, raises D401 if 'property' is not in '--property-decorators'
        return "property"

    @cached_property
    def my_cached_property(self) -> str:
        """This is my cached property."""
        # non-imperative docstring, raises D401 if 'cached_property' is not in '--property-decorators'
        return "cached_property"

Addendum

Suggested HISTORY.rst entries for the next release:

- Add ``--ignore-self-only-init`` option to suppress D107 ("missing method
  docstring") if ``__init__`` has no parameters other than ``self``.
  (Requires pydocstyle >= 6.3.0)

- Add ``--property-decorators`` option to suppress D401 ("not in imperative
  mood") for docstrings of properties, defaulting to ``property``,
  ``cached_property``, and ``functools.cached_property``.
  (Requires pydocstyle >= 6.2.0)

self.source,
self.filename,
ignore_decorators=self.ignore_decorators,
**check_source_kwargs,
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for using kwargs here. pydocstyle has had a bunch of issues with other integrations using positional args

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

Successfully merging this pull request may close these issues.

3 participants