mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autodoc: Fix enable mocks on importing module
This commit is contained in:
@@ -1809,12 +1809,14 @@ class UninitializedGlobalVariableMixin(DataDocumenterMixinBase):
|
||||
except ImportError as exc:
|
||||
# annotation only instance variable (PEP-526)
|
||||
try:
|
||||
parent = importlib.import_module(self.modname)
|
||||
annotations = get_type_hints(parent, None, self.config.autodoc_type_aliases)
|
||||
if self.objpath[-1] in annotations:
|
||||
self.object = UNINITIALIZED_ATTR
|
||||
self.parent = parent
|
||||
return True
|
||||
with mock(self.config.autodoc_mock_imports):
|
||||
parent = importlib.import_module(self.modname)
|
||||
annotations = get_type_hints(parent, None,
|
||||
self.config.autodoc_type_aliases)
|
||||
if self.objpath[-1] in annotations:
|
||||
self.object = UNINITIALIZED_ATTR
|
||||
self.parent = parent
|
||||
return True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user