From 26b7d729a252ab917de5e638d84868b860c6a7d3 Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Sun, 27 Jun 2021 16:54:36 -0700 Subject: [PATCH] Fixed AttributeError using inheritance diagrams on a module with plain imports Fixes #289 --- CHANGELOG.rst | 14 ++++++++------ autoapi/inheritance_diagrams.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 32e07f0..abd3e78 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -94,7 +94,7 @@ Breaking Changes Features ^^^^^^^^ -* Added support for using type hints as parameter types and return types +* (Python) Added support for using type hints as parameter types and return types via the ``sphinx.ext.autodoc.typehints`` extension. * `#191 `: Basic incremental build support is enabled ``autoapi_keep_files`` is enabled. @@ -109,16 +109,18 @@ Features Bug Fixes ^^^^^^^^^ -* `#246 `: +* `#246 `: (Python) Fixed TypeError when parsing a class that inherits from ``type``. * `#244 `: Fixed an unnecessary deprecation warning being raised when running sphinx-build from the same directory as conf.py. -* Fixed properties documented by Autodoc directives geting documented as methods. +* (Python) Fixed properties documented by Autodoc directives geting documented as methods. * `#293 `: Fixed failure to build out of source conf.py files. Configuration values using relative values are now relative to the source directory instead of relative to the conf.py file. +* `#289 `: (Python) + Fixed AttributeError using inheritance diagrams on a module with plain imports. V1.5.1 (2020-10-01) @@ -140,7 +142,7 @@ Features * `#222 `: Declare the extension as parallel unsafe. -* `#217 `: +* `#217 `: (Python) All overload signatures are documented. * `#243 `: Files are found in order of preference according to ``autoapi_file_patterns``. @@ -149,9 +151,9 @@ Features Bug Fixes ^^^^^^^^^ -* `#219 `: +* `#219 `: (Python) Fixed return types not showing for methods. -* Fixed incorrect formatting of properties on generated method directives. +* (Python) Fixed incorrect formatting of properties on generated method directives. * Fixed every toctree entry getting added as a new list. * `#234 `: Fixed only some entries getting added to the toctree. diff --git a/autoapi/inheritance_diagrams.py b/autoapi/inheritance_diagrams.py index f905dc2..0f3d935 100644 --- a/autoapi/inheritance_diagrams.py +++ b/autoapi/inheritance_diagrams.py @@ -12,7 +12,7 @@ def _do_import_class(name, currmodule=None): while target and path_stack: path_part = path_stack.pop() target = (target.getattr(path_part) or (None,))[0] - while isinstance(target, astroid.ImportFrom): + while isinstance(target, (astroid.ImportFrom, astroid.Import)): try: target = target.do_import_module(path_part) except astroid.AstroidImportError: