'sphinx autosummary: "failed to import Child.model" (inherited instance attribute)

I'm having trouble with sphinx and autosummary. Apparently, sphinx is unable to document inherited instance attributes. For some reason, the resulting error is an import error.

python code:

class Base:
    """Base class."""

    def __init__(self, **kwargs):
        self.model = None
        """An attribute."""

class Child(Base):
    """Child class."""

    def __init__(self, **kwargs):

rst documentation file:

.. autosummary::
    :toctree: generated


when I run make html I get the following error:

.../new_docs/generated/mylib.Child.rst:24: WARNING: autosummary: failed to import Child.model

Notice that everything else is imported correctly, so this is not a path issue.

Is it possible to resolve this problem? I'm using sphinx-build 4.3.0.


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source