summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-02 18:36:42 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-02 22:54:12 +0900
commitc7a63b455c6b26c08702928cd826da508210c89f (patch)
treecfd04bd4224bbcf9fb80260713295a0fec2b88ec
parent56772395bb945099a6d5331501c179dd2831fa1c (diff)
downloadsphinx-git-c7a63b455c6b26c08702928cd826da508210c89f.tar.gz
refactor: autodoc: Update type annotations
-rw-r--r--sphinx/ext/autodoc/__init__.py2
-rw-r--r--sphinx/ext/autodoc/importer.py10
2 files changed, 7 insertions, 5 deletions
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index eae199b33..29bfb791c 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -849,7 +849,7 @@ class ModuleDocumenter(Documenter):
if self.options.deprecated:
self.add_line(' :deprecated:', sourcename)
- def get_object_members(self, want_all: bool) -> Tuple[bool, List[Tuple[str, object]]]:
+ def get_object_members(self, want_all: bool) -> Tuple[bool, List[Tuple[str, Any]]]:
if want_all:
if (self.options.ignore_module_all or not
hasattr(self.object, '__all__')):
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py
index 432aa0c85..cdccf710d 100644
--- a/sphinx/ext/autodoc/importer.py
+++ b/sphinx/ext/autodoc/importer.py
@@ -11,10 +11,10 @@
import importlib
import traceback
import warnings
-from collections import namedtuple
-from typing import Any, Callable, Dict, List, Mapping, Tuple
+from typing import Any, Callable, Dict, List, Mapping, NamedTuple, Tuple
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
+from sphinx.pycode import ModuleAnalyzer
from sphinx.util import logging
from sphinx.util.inspect import isclass, isenumclass, safe_getattr
@@ -122,11 +122,13 @@ def get_module_members(module: Any) -> List[Tuple[str, Any]]:
return sorted(list(members.values()))
-Attribute = namedtuple('Attribute', ['name', 'directly_defined', 'value'])
+Attribute = NamedTuple('Attribute', [('name', str),
+ ('directly_defined', bool),
+ ('value', Any)])
def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
- analyzer: Any = None) -> Dict[str, Attribute]:
+ analyzer: ModuleAnalyzer = None) -> Dict[str, Attribute]:
"""Get members and attributes of target object."""
from sphinx.ext.autodoc import INSTANCEATTR