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
works yielding {'type': 'function', 'docstring': '', 'deprecated': False, 'file': '<string>', 'file_line': None, 'errors': [('GL08', 'The object does not have a docstring')], 'examples_errors': ''} but changing to numpydoc==1.90 gives
Traceback (most recent call last):
File ".../doctest.py", line 18, in <module>
print(validate(x))
File ".../uv/environments-v2/doctest-76a1dd0b6c7db47d/lib/python3.9/site-packages/numpydoc/validate.py", line 648, in validate
cls = Validator._load_obj(f"{doc.code_obj.__module__}.{cls_name}")
File ".../uv/environments-v2/doctest-76a1dd0b6c7db47d/lib/python3.9/site-packages/numpydoc/validate.py", line 268, in _load_obj
obj = getattr(obj, part)
AttributeError: module '__main__' has no attribute '__create_fn__'
The error only arises with the @dataclass annotation.
Here the _set_new_attribute is responsible for binding the __init__ function to the new class.
It looks like in Python 3.9, there is no support in the dataclasses [Py3.9] library for setting __qualname__ for the created instances/functions by _set_new_attribute - the only reference to __qualname__ is in creating a __repr__ function.
In Python 3.10, many __qualname__ modificaitons are introduced to dataclasses [Py3.10], including all uses of the _set_new_attribute method.
@rossbar I'm not familiar enough with this sort of bug to know if we ought to introduce a python version specific fix. Python 3.9 end of life is Oct 2025 as well, if relevant? This issue is very much localized to dataclasses.
My vote would be to require Python 3.10+ for numpydoc. It's maybe a few months earlier than we would have preferred to make the jump but seems reasonable. People on 3.9 and older can use older versions if needed
Activity
DerWeh commentedon Jun 28, 2025
I have the same issue, in case further logs help you:
https://app.readthedocs.org/projects/gftools/builds/28675578/
https://github.com/DerWeh/gftools/actions/runs/15946217959/job/44980605108?pr=45
mattgebert commentedon Jul 22, 2025
@DerWeh it seems your bug is the same as #638, but distinct from this one.
@EthanAtLL I've gone through the code the this issue arises from the use of the
code_objto resolve the parent class (via__qualname__attribute).__qualname__was introduced in Python 3.3. In thedataclasses.pymodule, the processing path for adding the__qualname__for__init__isHere the
_set_new_attributeis responsible for binding the__init__function to the new class.It looks like in Python 3.9, there is no support in the
dataclasses [Py3.9]library for setting__qualname__for the created instances/functions by_set_new_attribute- the only reference to__qualname__is in creating a__repr__function.In Python 3.10, many
__qualname__modificaitons are introduced todataclasses [Py3.10], including all uses of the_set_new_attributemethod.@rossbar I'm not familiar enough with this sort of bug to know if we ought to introduce a python version specific fix. Python 3.9 end of life is Oct 2025 as well, if relevant? This issue is very much localized to dataclasses.
larsoner commentedon Jul 22, 2025
My vote would be to require Python 3.10+ for
numpydoc. It's maybe a few months earlier than we would have preferred to make the jump but seems reasonable. People on 3.9 and older can use older versions if neededEthanAtLL commentedon Jul 22, 2025
@mattgebert Thank you for looking into this! @larsoner With 3.9 EOLing soon, requiring 3.10+ makes sense.
build(pyproject.toml): drop support for python 3.9 (require 3.10+)
build(pyproject.toml): drop support for python 3.9 (require 3.10+) (#641