[Bug]: Defining custom class without docval prevents read
What happened?
Example here: https://github.com/bendichter/ndx-anatomical-localization/issues/1
When the constructor of a registered class uses a list of arguments instead of docval as in:
@register_class("Space", "ndx-anatomical-localization")
class Space(TempSpace):
def __init__(self, name, space_name, origin, units, orientation):
The construct process relies on docval to set the kwargs that are passed to the class constructor:
# build kwargs for the constructor
kwargs = dict()
for const_arg in get_docval(cls.__init__):
# ...
kwargs[argname] = val
try:
obj = self.__new_container__(cls, builder.source, parent, builder.attributes.get(self.__spec.id_key()),
**kwargs)
Here, kwargs is empty. This results in a ConstructError on the last line above that says all required arguments are missing.
I suggest we change the construct process to use https://docs.python.org/3.12/library/inspect.html#introspecting-callables-with-the-signature-object in addition to docval until docval is removed.
This is not blocking because extension builders can still define their __init__ with docval, but it would be nice to change as we transition away from using docval.
Steps to Reproduce
See example above
Traceback
No response
Operating System
macOS
Python Executable
Conda
Python Version
3.12
Package Versions
No response