Skip to content

load_namespace fails when default_type_map is None #94

Description

@rly

The default_type_map=None branch of load_namespace is broken — it calls NamespaceCatalog and reads attributes that don't exist on it.

Bugs

  • hdmf_docutils/generate_format_docs.py:121 does NamespaceCatalog(default_namespace, ...), but NamespaceCatalog.__init__'s signature is (group_spec_cls, dataset_spec_cls, spec_namespace_cls, core_namespaces=[]). Passing a str positionally fails docval type-checking with TypeError: NamespaceCatalog.__init__: incorrect type for 'core_namespaces' (got 'str', expected 'list').
  • hdmf_docutils/doctools/renderrst.py:331 accesses namespace_catalog.default_namespace, which is not an attribute of NamespaceCatalog.

NamespaceCatalog has never had a default_namespace parameter or attribute (verified back to 3.14.6), so these have always been broken. The bug went unnoticed because real callers always pass a non-None default_type_map, taking the other branch.

Trigger

Surfaces in NeurodataWithoutBorders/nwb-schema#663, which sets spec_default_type_map = None to avoid rendering docs against a stale core namespace bundled in pynwb. RTD build log: https://app.readthedocs.org/projects/nwb-schema/builds/32573738/.

Fix

  • Drop the bogus first positional from the NamespaceCatalog call; pass core_namespaces=[default_namespace] instead.
  • Replace namespace_catalog.default_namespace with namespace_catalog.core_namespaces[0] (with a clear error if empty).

Metadata

Metadata

Assignees

Labels

category: bugerrors in the code or code behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions