You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
numpydoc validate can crash checking GL08 with a locally-scoped class #717
#622 fixed the GL08 check for nested classes, but it introduced a crash in validate() for classes that are defined inside a function, if the constructor does not have a docstring.
deffactory():
classLocalClass:
def__init__(self, value):
# no docstringself.value=valuereturnLocalClassMyClass=factory()
With the example above in factory.py:
$ python -m numpydoc validate factory.MyClass.__init__
Traceback (most recent call last):
File "<frozen runpy>", line 203, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File ".../site-packages/numpydoc/__main__.py", line 7, in <module>
raise SystemExit(main())
~~~~^^
File ".../site-packages/numpydoc/cli.py", line 138, in main
return func(**args)
File ".../site-packages/numpydoc/cli.py", line 25, in validate_object
results = validate(import_path)
File ".../site-packages/numpydoc/validate.py", line 675, in validate
cls = Validator._load_obj(f"{doc.code_obj.__module__}.{cls_name}")
File ".../site-packages/numpydoc/validate.py", line 268, in _load_obj
obj = getattr(obj, part)
AttributeError: 'function' object has no attribute '<locals>'
Here, __qualname__ is factory.<locals>.LocalClass.__init__. The local namespace is not being handled.
Activity
mattgebert commentedon Nov 5, 2026
Thanks for this - will take a look into handling this case shortly! Sorry it's cause a regression.