Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-06-06 19:40:20 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-06-06 19:40:23 +0300
commitf98987b24ecff3c5d30ecb34ce0c8515132cde87 (patch)
treeefb201c7e7c7319f1783cb1d010f29c7b224ef30
parentcb5e094c0aee9cbfce56991c78dfe95a688ed5ab (diff)
Fix #7791: autodoc: TypeError is raised on documenting singledispatch function
-rw-r--r--CHANGES1
-rw-r--r--sphinx/ext/autodoc/__init__.py19
2 files changed, 18 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 38a062516..988a29260 100644
--- a/CHANGES
+++ b/CHANGES
@@ -121,6 +121,7 @@ Bugs fixed
* #7668: autodoc: wrong retann value is passed to a handler of
autodoc-proccess-signature
* #7711: autodoc: fails with ValueError when processing numpy objects
+* #7791: autodoc: TypeError is raised on documenting singledispatch function
* #7551: autosummary: a nested class is indexed as non-nested class
* #7661: autosummary: autosummary directive emits warnings twices if failed to
import the target module
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index 31301e01e..109708d0e 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1222,7 +1222,15 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
"""Annotate type hint to the first argument of function if needed."""
- sig = inspect.signature(func)
+ try:
+ sig = inspect.signature(func)
+ except TypeError as exc:
+ logger.warning(__("Failed to get a function signature for %s: %s"),
+ self.fullname, exc)
+ return
+ except ValueError:
+ return
+
if len(sig.parameters) == 0:
return
@@ -1769,7 +1777,14 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
"""Annotate type hint to the first argument of function if needed."""
- sig = inspect.signature(func)
+ try:
+ sig = inspect.signature(func)
+ except TypeError as exc:
+ logger.warning(__("Failed to get a method signature for %s: %s"),
+ self.fullname, exc)
+ return
+ except ValueError:
+ return
if len(sig.parameters) == 1:
return