Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

D401 "not in imperative mood" not truly applicable to @property #531

Closed
stefano-xy opened this issue Apr 9, 2021 · 5 comments
Closed

D401 "not in imperative mood" not truly applicable to @property #531

stefano-xy opened this issue Apr 9, 2021 · 5 comments

Comments

@stefano-xy
Copy link

@property methods are not used as methods. Their docstrings are used to set the description of the properties. Errors like D401 "docstring not in imperative mood" should not be applicable to methods, at least to getters, that define a @property.

IMHO, the following docstring should be accepted for x, although not in imperative mood:

@property
def x(self):
    "The X property"
    return self._x

Alternatively, please classify these errors differently, so users can switch them off.

@stefano-xy
Copy link
Author

Same for DAR201, I don't think :returns: is mandatory when the property description is a multiline string.

@samj1912
Copy link
Member

You should be able to use --ignore-decorators to ignore pydocstyle errors for certain decorated callables.

http://www.pydocstyle.org/en/stable/usage.html

DAR201 is not raised by pydocstyle.

@WasabiFan
Copy link

The above suggested workaround (--ignore-decorators) seems to only allow entirely disabling pydocstyle for all @property docstrings. I appreciate the availability of a workaround but I think this one isn't sufficiently surgical to effectively unblock a user here.

What is the suggested/intended "mood" for a property docstring otherwise? I guess "Return the X property"?

@sigmavirus24
Copy link
Member

but I think this one isn't sufficiently surgical to effectively unblock a user here.

What is blocking a user from your perspective? How should this be more "surgical"?

What is the suggested/intended "mood" for a property docstring otherwise? I guess "Return the X property"?

How do you document the attributes/properties of classes otherwise?

@samj1912
Copy link
Member

Fixed by #546

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants