|
6 | 6 | from pydoclint.utils.astTypes import FuncOrAsyncFuncDef
|
7 | 7 | from pydoclint.utils.doc import Doc
|
8 | 8 | from pydoclint.utils.generic import (
|
9 |
| - checkIsAbstractMethod, |
10 | 9 | collectFuncArgs,
|
11 | 10 | detectMethodType,
|
12 | 11 | generateMsgPrefix,
|
13 | 12 | getDocstring,
|
14 |
| - isPropertyMethod, |
15 | 13 | )
|
16 | 14 | from pydoclint.utils.internal_error import InternalError
|
17 | 15 | from pydoclint.utils.method_type import MethodType
|
|
27 | 25 | isReturnAnnotationNone,
|
28 | 26 | isReturnAnnotationNoReturn,
|
29 | 27 | )
|
| 28 | +from pydoclint.utils.special_methods import ( |
| 29 | + checkIsAbstractMethod, |
| 30 | + checkIsPropertyMethod, |
| 31 | +) |
30 | 32 | from pydoclint.utils.violation import Violation
|
31 | 33 | from pydoclint.utils.visitor_helper import (
|
32 | 34 | checkReturnTypesForViolations,
|
@@ -485,11 +487,12 @@ def checkReturns( # noqa: C901
|
485 | 487 | hasGenAsRetAnno: bool = hasGeneratorAsReturnAnnotation(node)
|
486 | 488 | onlyHasYieldStmt: bool = hasYieldStmt and not hasReturnStmt
|
487 | 489 | hasIterAsRetAnno: bool = hasIteratorOrIterableAsReturnAnnotation(node)
|
| 490 | + isPropertyMethod: bool = checkIsPropertyMethod(node) |
488 | 491 |
|
489 | 492 | docstringHasReturnSection: bool = doc.hasReturnsSection
|
490 | 493 |
|
491 | 494 | violations: List[Violation] = []
|
492 |
| - if not docstringHasReturnSection and not isPropertyMethod(node): |
| 495 | + if not docstringHasReturnSection and not isPropertyMethod: |
493 | 496 | if (
|
494 | 497 | # fmt: off
|
495 | 498 | not (onlyHasYieldStmt and hasIterAsRetAnno)
|
@@ -541,6 +544,12 @@ def checkReturns( # noqa: C901
|
541 | 544 | # to check for DOC203 violations.
|
542 | 545 | return violations
|
543 | 546 |
|
| 547 | + if returnSec == [] and isPropertyMethod: |
| 548 | + # No need to check return type for methods with "@property" |
| 549 | + # decorator. This is because it's OK for @property methods |
| 550 | + # to have no return section in the docstring. |
| 551 | + return violations |
| 552 | + |
544 | 553 | checkReturnTypesForViolations(
|
545 | 554 | style=self.style,
|
546 | 555 | returnAnnotation=returnAnno,
|
|
0 commit comments