Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/violation_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Other potential causes to `DOC103` include:
| `DOC202` | Function/method has a return section in docstring, but there are no return statements or annotations |
| `DOC203` | Return type(s) in the docstring not consistent with the return annotation |

Note on `DOC201`: Methods with `@property` as its last decorator do not need to
Copy link
Owner

Choose a reason for hiding this comment

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

I think we need to replace "its last decorator" with "its outer-most decorator (i.e., on the top)"

have a return section.
Note on `DOC201`: Methods with `@property` as a decorator do not need to have a
return section.

## 3. `DOC3xx`: Violations about class docstring and class constructor

Expand Down
2 changes: 1 addition & 1 deletion pydoclint/utils/special_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def checkMethodContainsSpecifiedDecorator(
and any(
( # noqa: PAR001
isinstance(_, ast.Name)
and hasattr(node.decorator_list[-1], 'id')
Copy link
Author

Choose a reason for hiding this comment

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

in the new test case, abstractmethod is the last element in the decorator list and it does not (at that time) have an id attribute, so this test failed despite there being a @property decorator.

Copy link
Owner

Choose a reason for hiding this comment

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

Given my reply below (#261 (comment)), I think we'd need to change this line into:

and hasattr(node.decorator_list[0], 'id')

and hasattr(_, 'id')
and _.id == decorator
)
for _ in node.decorator_list
Expand Down
16 changes: 16 additions & 0 deletions tests/data/common/property_method.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import abc


class MyClass:
data: float = 2.1

Expand All @@ -10,3 +13,16 @@ def something(self) -> float:
is a "property method" and is intended to be used as an attribute.
"""
return self.data

class AbstractClass(abc.ABC):
def __init__(self):
pass

@property
@abc.abstractmethod
def something(self) -> float:
"""
Some abstract property.

This is also OK; @property does not have to be the inner decorator.
"""
Loading