Skip to content

Fix parsing of __init__ GL08 error on top-level classes with correct docstrings - #704

Open
flowln wants to merge 2 commits into
numpy:mainfrom
flowln:fix/init-documentation-on-ctor
Open

Fix parsing of __init__ GL08 error on top-level classes with correct docstrings#704
flowln wants to merge 2 commits into
numpy:mainfrom
flowln:fix/init-documentation-on-ctor

Conversation

@flowln

@flowln flowln commented Aug 17, 2026

Copy link
Copy Markdown

When adding a __init__ parameter documentation to a top-level class of a module, it is currently not being considered for passing the need to document the __init__ method itself. The first commit modifies a test case to expose the faulty behavior, and the subsequent patch fixes that case by ensuring non-nested classes get properly parsed.

flowln added 2 commits August 17, 2026 15:18
The test is kept passing, though it shows a bug currently in the code:
when adding a __init__ parameter documentation to a top-level class of
a module, it is currently not being considered for passing the need to
document the __init__ method itself.

Signed-off-by: Sofia Donato Ferreira <sofia.ferreira@lnls.br>
When considering the ancestors of a __init__ method inside a top-level
class, we often get the following:

<module node>.<class node> (<method node> is the node being considered)

This means that in those cases, len(ancestors) == 2, since the method
node is not included in the ancestors list.

This fixes the error introduced in the previous patch, as well as a
previous instance of something similar, where __init__ doesn't provide
a docstring, and the class docstring doesn't have a Parameters section,
but since the __init__ method has no parameters outside of self, it ought
to be considered correct to not have a docstring there too.

Signed-off-by: Sofia Donato Ferreira <sofia.ferreira@lnls.br>
flowln added a commit to cnpem/sophys-common that referenced this pull request Aug 21, 2026
The GL08 ignores at the __init__ methods are only needed since
numpy/numpydoc#704 is not in yet.

Signed-off-by: Sofia Donato Ferreira <sofia.ferreira@lnls.br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant