From b6e8f630665dc5c57f7c48eec276bdbf12759dd5 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 6 May 2020 01:30:26 +0900 Subject: [PATCH] refactor: autodoc: if-block for callable object is no longer needed The if-block for callable object was added to FunctionDocumenter at 5c3a0e4e40 (see #5447). At that time, it helps to introspect the function signature for a callable object because ``sphinx.util.inspect:Signature`` emits a warning when a callable object is given. For now, ``sphinx.util.inspect:signature()` does not emit a warning even if a callable object is given. So this if-block is no longer needed. --- sphinx/ext/autodoc/__init__.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 3a0736390..7cf8b584b 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1045,18 +1045,8 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ # cannot introspect arguments of a C function or method return None try: - if (not inspect.isfunction(unwrapped) and - not inspect.ismethod(unwrapped) and - not inspect.isbuiltin(unwrapped) and - not inspect.is_cython_function_or_method(unwrapped) and - not inspect.isclass(unwrapped) and - hasattr(unwrapped, '__call__')): - self.env.app.emit('autodoc-before-process-signature', - unwrapped.__call__, False) - sig = inspect.signature(unwrapped.__call__) - else: - self.env.app.emit('autodoc-before-process-signature', unwrapped, False) - sig = inspect.signature(unwrapped) + self.env.app.emit('autodoc-before-process-signature', unwrapped, False) + sig = inspect.signature(unwrapped) args = stringify_signature(sig, **kwargs) except TypeError: if (inspect.is_builtin_class_method(unwrapped, '__new__') and