Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy loading modules causes sphinx documentation to break #37

Open
rsokolewicz opened this issue Dec 16, 2022 · 4 comments
Open

lazy loading modules causes sphinx documentation to break #37

rsokolewicz opened this issue Dec 16, 2022 · 4 comments

Comments

@rsokolewicz
Copy link

Hi,

I found an issue where building a sphinx documentation breaks when one of our package's dependencies lazy loads a package.

In our particular case we depend on qcodes that lazy loads the h5py package.

When building the documentation, it fails with the following trace stack

[AutoAPI] Reading files... [  1%] /home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/checkouts/545/quantify_scheduler/gettables_profiled.py

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/autoapi/extension.py", line 164, in run_autoapi
    if sphinx_mapper_obj.load(
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/autoapi/mappers/python/mapper.py", line 306, in load
    data = self.read_file(path=path, dir_root=dir_root)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/autoapi/mappers/python/mapper.py", line 323, in read_file
    parsed_data = Parser().parse_file(path)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/autoapi/mappers/python/parser.py", line 41, in parse_file
    return self._parse_file(
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/autoapi/mappers/python/parser.py", line 37, in _parse_file
    node = astroid.builder.AstroidBuilder().file_build(file_path, module_name)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/astroid/builder.py", line 135, in file_build
    return self._post_build(module, builder, encoding)
 ...
   File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/astroid/raw_building.py", line 82, in attach_const_node
    _attach_local_node(node, nodes.const_factory(value), name)
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5531, in const_factory
    instance.postinit(_create_dict_items(value, instance))
  File "/home/docs/checkouts/readthedocs.org/user_builds/quantify-quantify-scheduler/envs/545/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5502, in _create_dict_items
    for key, value in values.items():
RuntimeError: dictionary changed size during iteration

which is not very clear to me. I can make the build succeed by adding the line import h5py to docs/conf.py, so the root cause is very likely due to the lazy loading of h5py.

I don't have a nice minimal working example, other than cloning our repo and building the documentation yourselves:

mkdir tmp
cd tmp
git clone --no-single-branch --depth 50 [email protected]:quantify-os/quantify-scheduler.git .
git fetch origin --force --tags --prune --prune-tags --depth 50 merge-requests/545/head:external-545
git checkout --force a7cc1ff360a2da8bb64f44f405a5b7bc5f3389fc
git clean -d -f -f
conda create --name tmp python=3.8
conda activate tmp
pip install quantify-scheduler
pip install -r requirements_dev.txt
pip install qcodes==0.36.0
cd docs
python -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html

which fails, but after a echo "import h5py" >> conf.py and running the sphinx build again it succeeds.

@stefanv
Copy link
Member

stefanv commented Mar 13, 2023

Before I investigate further, can you confirm that this is still an issue @rsokolewicz?

@rsokolewicz
Copy link
Author

Hi Stefan, it's still an issue yes, but it doesn't block any of our development. As I mentioned, we can add an import h5py line to conf.py that is used by sphinx when building the documentation and resolves the issue.

I was playing around just now and can tell you that the error is caused by the autoapi extension of sphinx. This generates an API page with documentation and cross references to all modules/classes/methods. My guess is that something goes wrong in creating a cross reference to a member of a lazy loaded package. It could very well be that the issue should be solved by autoapi and not you guys.

@stefanv
Copy link
Member

stefanv commented Mar 15, 2024

Is this the same traceback you see?

Traceback (most recent call last):
  File "/tmp/venv2/lib64/python3.10/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/tmp/venv2/lib64/python3.10/site-packages/autoapi/extension.py", line 153, in run_autoapi
    if sphinx_mapper_obj.load(
  File "/tmp/venv2/lib64/python3.10/site-packages/autoapi/mappers/python/mapper.py", line 300, in load
    data = self.read_file(path=path, dir_root=dir_root)
  File "/tmp/venv2/lib64/python3.10/site-packages/autoapi/mappers/python/mapper.py", line 318, in read_file
    parsed_data = Parser().parse_file(path)
  File "/tmp/venv2/lib64/python3.10/site-packages/autoapi/mappers/python/parser.py", line 41, in parse_file
    return self._parse_file(
  File "/tmp/venv2/lib64/python3.10/site-packages/autoapi/mappers/python/parser.py", line 37, in _parse_file
    node = astroid.builder.AstroidBuilder().file_build(file_path, module_name)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 1162, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/protocols.py", line 412, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == "metaclass"
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1874, in _class_type
    if _is_metaclass(klass):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1845, in _is_metaclass
    for baseobj in base.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 1162, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/protocols.py", line 412, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == "metaclass"
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1874, in _class_type
    if _is_metaclass(klass):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1845, in _is_metaclass
    for baseobj in base.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 377, in infer_attribute
    yield from owner.igetattr(self.attrname, context)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 173, in _post_build
    module = self._manager.visit_transforms(module)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 109, in visit_transforms
    return self._transform.visit(node)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 89, in visit
    return self._visit(module)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 54, in _visit
    visited = self._visit_generic(value)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 61, in _visit_generic
    return [self._visit_generic(child) for child in node]
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 61, in <listcomp>
    return [self._visit_generic(child) for child in node]
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 67, in _visit_generic
    return self._visit(node)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 57, in _visit
    return self._transform(node)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/transforms.py", line 38, in _transform
    if predicate is None or predicate(node):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/brain/brain_namedtuple_enum.py", line 600, in _is_enum_subclass
    return cls.is_subtype_of("enum.Enum")
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2238, in is_subtype_of
    return any(anc.qname() == type_name for anc in self.ancestors(context=context))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2238, in <genexpr>
    return any(anc.qname() == type_name for anc in self.ancestors(context=context))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2399, in ancestors
    for baseobj in stmt.infer(context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 270, in infer_call
    for callee in self.func.infer(context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 358, in infer_attribute
    for owner in self.expr.infer(context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 304, in infer_import
    yield self.do_import_module(self.real_name(name))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 279, in infer_call
    yield from callee.infer_call_result(caller=self, context=callcontext)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2291, in infer_call_result
    result = self._infer_type_call(caller, context)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2242, in _infer_type_call
    name_node = next(caller.args[0].infer(context))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 270, in infer_call
    for callee in self.func.infer(context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 358, in infer_attribute
    for owner in self.expr.infer(context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/inference.py", line 304, in infer_import
    yield self.do_import_module(self.real_name(name))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 221, in ast_from_module_name
    return self.ast_from_module(named_module, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/manager.py", line 328, in ast_from_module
    return AstroidBuilder(self).module_build(module, modname)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/builder.py", line 101, in module_build
    node = self.inspect_build(module, modname=modname, path=path)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/raw_building.py", line 404, in inspect_build
    self.object_build(node, module)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/raw_building.py", line 455, in object_build
    attach_const_node(node, name, member)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/raw_building.py", line 78, in attach_const_node
    _attach_local_node(node, nodes.const_factory(value), name)
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_classes.py", line 5641, in const_factory
    instance.postinit(_create_dict_items(value, instance))
  File "/tmp/venv2/lib64/python3.10/site-packages/astroid/nodes/node_classes.py", line 5612, in _create_dict_items
    for key, value in values.items():
RuntimeError: dictionary changed size during iteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tmp/venv2/lib64/python3.10/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/tmp/venv2/lib64/python3.10/site-packages/sphinx/application.py", line 262, in __init__
    self._init_builder()
  File "/tmp/venv2/lib64/python3.10/site-packages/sphinx/application.py", line 335, in _init_builder
    self.events.emit('builder-inited')
  File "/tmp/venv2/lib64/python3.10/site-packages/sphinx/events.py", line 105, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function run_autoapi at 0x7f3126e61090> for event 'builder-inited' threw an exception (exception: dictionary changed size during iteration)

Thanks for the reproducer, although I hope we can find one with fewer than 223 dependencies!

@rsokolewicz
Copy link
Author

looks like it, yes :) As I said before, we are not blocked by this since we found a way around it: add an import h5py to conf.py. Unless other people have the same problem I wouldn't invest too much time into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants