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
14 changes: 14 additions & 0 deletions numpydoc/tests/hooks/example_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,17 @@ def deprecated_function():
--------
>>> result = 1 + 1
"""


class GoodConstructor: # numpydoc ignore=EX01,ES01,SA01
"""
A class providing its constructor docstring in the class documentation.

Parameters
----------
name : str
The name of the new class.
"""

def __init__(self, name):
self.name = name
4 changes: 0 additions & 4 deletions numpydoc/tests/hooks/test_validate_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def test_validate_hook(example_module, config, capsys):

{example_module!s}:8: EX01 No examples section found

{example_module!s}:11: GL08 The object does not have a docstring

{example_module!s}:17: ES01 No extended summary found

{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented
Expand Down Expand Up @@ -97,8 +95,6 @@ def test_validate_hook_with_ignore(example_module, capsys):
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

{example_module!s}:11: GL08 The object does not have a docstring

{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

{example_module!s}:17: PR07 Parameter "*args" has no description
Expand Down
2 changes: 1 addition & 1 deletion numpydoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def validate(obj_name, validator_cls=None, **validator_kwargs):
cls_doc = Validator(get_doc_object(cls))
elif isinstance(doc, AstValidator): # Supports class traversal for ASTs.
ancestry = doc.ancestry
if len(ancestry) > 2: # e.g. module.class.__init__
if len(ancestry) >= 2: # e.g. module.class.__init__
parent = doc.ancestry[-1] # Get the parent
cls_name = ".".join(
[
Expand Down