Skip to content

Commit d8f05e6

Browse files
committed
fix(validate.py): Considers subclass nesting when checking GL08 constructor
Introduced GL08 checking for constructors (i.e. __init__) but didn't traverse the parent class heireacy when importing the __init__ parent from a module.
1 parent a36287a commit d8f05e6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

numpydoc/validate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
645645
and doc.is_function_or_method
646646
and hasattr(doc, "code_obj")
647647
):
648-
cls_name = doc.code_obj.__qualname__.split(".")[0]
648+
cls_name = ".".join(
649+
doc.code_obj.__qualname__.split(".")[:-1]
650+
) # Collect all class depths before the constructor.
649651
cls = Validator._load_obj(f"{doc.code_obj.__module__}.{cls_name}")
650652
# cls = Validator._load_obj(f"{doc.name[:-9]}.{cls_name}") ## Alternative
651653
cls_doc = Validator(get_doc_object(cls))

0 commit comments

Comments
 (0)