refactor: autodoc: Do not fill parent field when not global variable

This commit is contained in:
Takeshi KOMIYA 2020-12-21 01:20:58 +09:00
parent a7e10c1d36
commit d7c490fefc

View File

@ -1809,11 +1809,11 @@ class UninitializedGlobalVariableMixin(DataDocumenterMixinBase):
except ImportError as exc: except ImportError as exc:
# annotation only instance variable (PEP-526) # annotation only instance variable (PEP-526)
try: try:
self.parent = importlib.import_module(self.modname) parent = importlib.import_module(self.modname)
annotations = get_type_hints(self.parent, None, annotations = get_type_hints(parent, None, self.config.autodoc_type_aliases)
self.config.autodoc_type_aliases)
if self.objpath[-1] in annotations: if self.objpath[-1] in annotations:
self.object = UNINITIALIZED_ATTR self.object = UNINITIALIZED_ATTR
self.parent = parent
return True return True
except ImportError: except ImportError:
pass pass