summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-01 18:23:24 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-01 18:27:16 +0900
commit9a44e4527704f17cca158b260b68a8dd37f95970 (patch)
tree584ac6b58d246beded5bcfac9d9e214c00c1f4b5 /sphinx
parent27b1a693d0574a083a58e8b485e15904c69ecee8 (diff)
downloadsphinx-git-9a44e4527704f17cca158b260b68a8dd37f95970.tar.gz
Fix #7613: autodoc: autodoc does not respect __signature__ of the class
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/ext/autodoc/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index 7343d41b6..3f2495882 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1391,7 +1391,12 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
# This sequence is copied from inspect._signature_from_callable.
# ValueError means that no signature could be found, so we keep going.
- # First, let's see if it has an overloaded __call__ defined
+ # First, we check the obj has a __signature__ attribute
+ if (hasattr(self.object, '__signature__') and
+ isinstance(self.object.__signature__, Signature)):
+ return None, None, self.object.__signature__
+
+ # Next, let's see if it has an overloaded __call__ defined
# in its metaclass
call = get_user_defined_function_or_method(type(self.object), '__call__')