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

D401 behaves differently in flake8-docstrings and pydocstyle #47

Closed
NMertsch opened this issue Jan 18, 2023 · 7 comments
Closed

D401 behaves differently in flake8-docstrings and pydocstyle #47

NMertsch opened this issue Jan 18, 2023 · 7 comments

Comments

@NMertsch
Copy link

Since PyCQA/pydocstyle#546, properties are exempt from D401 ("First line should be in imperative mood").

This plugin doesn't seem to reflect this.

Code:

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


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

    @property
    def my_property(self) -> str:
        """This is my property."""
        return "property"

    @cached_property
    def my_cached_property(self) -> str:
        """This is my cached property."""
        return "cached_property"

Versions and output:

$ python -V
Python 3.7.16
$ pydocstyle --version
6.3.0
$ flake8 --version
5.0.4 (flake8-docstrings: 1.6.0, mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.7.16 on Windows
$ pydocstyle code.py
[no output]
$ flake8 code.py
code.py:10:1: D401 First line should be in imperative mood; try rephrasing
code.py:15:1: D401 First line should be in imperative mood; try rephrasing
@sigmavirus24
Copy link
Member

Yeah, I suspect we need to add a similarly named option with the default set to the config constant pydocstyle created. Otherwise the internal API defaults are None and that's not what is desired.

@sigmavirus24
Copy link
Member

@NMertsch would you want to send a PR? I'd be happy to review and merge it

@NMertsch
Copy link
Author

Thank you for pointing at the potential cause, I'll give it a try in the next days.

@NMertsch
Copy link
Author

I'm able to fix it.

This option was introduced to pydocstyle in version 6.2.0 (Jan. 2nd 2023). Shall I update the minimum pydocstyle version in the requirements, or implement it in a backwards-compatible way?

@sigmavirus24
Copy link
Member

If you can do it a backwards compatible fashion that would be ideal, I think with a note as to when that can be dropped

@sigmavirus24
Copy link
Member

Also feel free to send a PR early for feedback so we can iterate more quickly to a solution

@NMertsch
Copy link
Author

Thank you @sigmavirus24 for merging #48, this issue is fixed now.

Can you please release the new version to PyPI? If there is something I can do to help, please let me know.

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

2 participants