-
Notifications
You must be signed in to change notification settings - Fork 189
Conversation
src/pydocstyle/parser.py
Outdated
def is_property(self): | ||
"""Return True iff the method decorated with property.""" | ||
for decorator in self.decorators: | ||
if "property" in decorator.name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure if I create a decorator named myproperty
this will disable D401 which is far from ideal. Why not if decorator.name == "property":
?
src/pydocstyle/parser.py
Outdated
@@ -218,6 +218,14 @@ def is_overload(self): | |||
return True | |||
return False | |||
|
|||
@property | |||
def is_property(self): | |||
"""Return True iff the method decorated with property.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This says iff
which tends to only mean "if and only if" but that's not actually true here because anything with the string "property" in the name will return True, not just the @property
built-in decorator
So if you want to catch both |
src/pydocstyle/parser.py
Outdated
@@ -218,6 +218,13 @@ def is_overload(self): | |||
return True | |||
return False | |||
|
|||
def is_property(self, decorators): | |||
"""Return True iff the method decorated with property.""" | |||
for decorator in self.decorators: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a hard time understanding what the difference is between self.decorators and the argument decorators. Can these names be more descriptive?
Also couldn't this be something like
return any(decorator.name in decorators for decorator in self.decorators)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve improved this. I also changed the above is_overload
to match.
This reverts commit caf8f42.
@TomFryers sorry for the delay. Thank you very much for this contribution :)! Also thanks @sigmavirus24 for reviewing :) |
This addresses issue #531. It excludes any method decorated with a decorator with "property" in the name in order to catch
cached_property
and other custom property types. Maybe there’s a fancier way of doing this, but I don’t know what it is.