Skip to content

Commit 752ab57

Browse files
committed
fix(validate.py): switched conditional GL08 check order to avoid property class failure for Validator.name
Solves Issue #638, though lacks property support for property class attributes.
1 parent 405ef2d commit 752ab57

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

numpydoc/validate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,14 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
647647
report_GL08: bool = True
648648
# Check if the object is a class and has a docstring in the constructor
649649
# Also check if code_obj is defined, as undefined for the AstValidator in validate_docstrings.py.
650-
if doc.name.endswith(".__init__") and doc.is_function_or_method:
650+
if doc.is_function_or_method and doc.name.endswith(".__init__"):
651+
# Import here at runtime to avoid circular import as
652+
# AstValidator is a subclass of Validator class without `doc_obj` attribute.
651653
from numpydoc.hooks.validate_docstrings import (
652654
AstValidator, # Support abstract syntax tree hook.
653655
)
654656

655-
if hasattr(doc, "code_obj"):
657+
if hasattr(doc, "code_obj"): # All Validator objects have this attr.
656658
cls_name = ".".join(
657659
doc.code_obj.__qualname__.split(".")[:-1]
658660
) # Collect all class depths before the constructor.

0 commit comments

Comments
 (0)