Skip to content

Commit

Permalink
Update docval to accept fully qualified class names
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Jan 20, 2024
1 parent 3a3dd59 commit e670d53
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hdmf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def check_type(value, argtype, allow_none=False):
return __is_float(value)
elif argtype == 'bool':
return __is_bool(value)
return argtype in [cls.__name__ for cls in value.__class__.__mro__]
cls_names = []
for cls in value.__class__.__mro__:
cls_names.append(f"{cls.__module__}.{cls.__qualname__}")
cls_names.append(cls.__name__)
return argtype in cls_names
elif isinstance(argtype, type):
if argtype is int:
return __is_int(value)
Expand Down Expand Up @@ -706,6 +710,11 @@ def to_str(argtype):
return ":py:class:`~{module}.{name}`".format(name=name, module=module.split('.')[0])
else:
return ":py:class:`~{module}.{name}`".format(name=name, module=module)
elif isinstance(argtype, str):
if "." in argtype: # type is (probably) a fully-qualified class name
return f":py:class:`~{argtype}`"
else: # type is locally resolved class name. just format as code
return f"``{argtype}``"
return argtype

def __sphinx_arg(arg):
Expand Down

0 comments on commit e670d53

Please sign in to comment.