Skip to content

AttributeError: 'ImportFrom' object has no attribute 'getattr' #500

@DanielGuo1

Description

@DanielGuo1

I have seen that the error (AttributeError: ‘ImportFrom’ object has no attribute ‘getattr’) has appeared in earlier versions as well
#193
#289

However, the issue also occurs for me with newer versions (<3.0). Here is the complete log:

# Platform:         win32; (Windows-10-10.0.19045-SP0)
# Sphinx version:   7.3.7
# Python version:   3.12.7 (CPython)
# Docutils version: 0.21.2
# Jinja2 version:   3.1.4
# Pygments version: 2.18.0

# Last messages:
#   writing output...
#   
#   building [html]: targets for 5 source files that are out of date
#   updating environment:
#   [new config]
#   18 added, 0 changed, 0 removed
#   
#   reading sources... [  6%]
#   autoapi/app/ar/index
#   

# Loaded extensions:
#   sphinx.ext.mathjax (7.3.7)
#   alabaster (0.7.16)
#   sphinxcontrib.applehelp (2.0.0)
#   sphinxcontrib.devhelp (2.0.0)
#   sphinxcontrib.htmlhelp (2.1.0)
#   sphinxcontrib.serializinghtml (1.1.10)
#   sphinxcontrib.qthelp (2.0.0)
#   sphinx.ext.autodoc.preserve_defaults (7.3.7)
#   sphinx.ext.autodoc.type_comment (7.3.7)
#   sphinx.ext.autodoc.typehints (7.3.7)
#   sphinx.ext.autodoc (7.3.7)
#   sphinx.ext.napoleon (7.3.7)
#   sphinx_autodoc_typehints (unknown version)
#   sphinx.ext.intersphinx (7.3.7)
#   sphinx.ext.autosummary (7.3.7)
#   sphinx.ext.graphviz (7.3.7)
#   sphinx.ext.inheritance_diagram (7.3.7)
#   autoapi.extension (3.2)
#   sphinx.ext.viewcode (7.3.7)
#   myst_parser (4.0.0)
#   sphinx_book_theme (1.1)
#   pydata_sphinx_theme (0.16.0)

  File "C:\Users\ABC\.conda\envs\project_A\Lib\site-packages\autoapi\inheritance_diagrams.py", line 14, in _do_import_class
    target = (target.getattr(path_part) or (None,))[0]
              ^^^^^^^^^^^^^^
AttributeError: 'ImportFrom' object has no attribute 'getattr'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needed: Reproduction CaseThis issue needs a small test case to reproduce the issue before it can be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions