diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-12-17 00:32:59 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-12-17 00:46:42 +0900 |
commit | 36e684bf83d14e587f0bf48eb0980f41ab66733e (patch) | |
tree | fb771f1d6b15f210c8c55aaa175b385a00fb7266 /sphinx/ext/autodoc/importer.py | |
parent | bec552c3efa9ce452dea8549c517428fcb98f30d (diff) | |
download | sphinx-git-36e684bf83d14e587f0bf48eb0980f41ab66733e.tar.gz |
refactor: Move _getmro() to sphinx.util.inspect module
Diffstat (limited to 'sphinx/ext/autodoc/importer.py')
-rw-r--r-- | sphinx/ext/autodoc/importer.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index cb97e0c72..ec05a8a3d 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -16,7 +16,8 @@ from typing import Any, Callable, Dict, List, Mapping, NamedTuple, Optional, Tup from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias from sphinx.pycode import ModuleAnalyzer from sphinx.util import logging -from sphinx.util.inspect import getannotations, getslots, isclass, isenumclass, safe_getattr +from sphinx.util.inspect import (getannotations, getmro, getslots, isclass, isenumclass, + safe_getattr) if False: # For type annotation @@ -165,12 +166,9 @@ Attribute = NamedTuple('Attribute', [('name', str), def _getmro(obj: Any) -> Tuple["Type", ...]: - """Get __mro__ from given *obj* safely.""" - __mro__ = safe_getattr(obj, '__mro__', None) - if isinstance(__mro__, tuple): - return __mro__ - else: - return tuple() + warnings.warn('sphinx.ext.autodoc.importer._getmro() is deprecated.', + RemovedInSphinx40Warning) + return getmro(obj) def _getannotations(obj: Any) -> Mapping[str, Any]: @@ -224,7 +222,7 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable, continue # annotation only member (ex. attr: int) - for i, cls in enumerate(_getmro(subject)): + for i, cls in enumerate(getmro(subject)): try: for name in getannotations(cls): name = unmangle(cls, name) |