Merge pull request #7823 from tk0miya/7821_overload_builtin_function

Fix #7821: autodoc: TypeError is raised for overloaded C-ext function
This commit is contained in:
Takeshi KOMIYA
2020-06-14 11:46:58 +09:00
committed by GitHub
2 changed files with 11 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ Bugs fixed
* #7808: autodoc: Warnings raised on variable and attribute type annotations
* #7802: autodoc: EOFError is raised on parallel build
* #7821: autodoc: TypeError is raised for overloaded C-ext function
* #7812: autosummary: generates broken stub files if the target code contains
an attribute and module that are same name
* #7811: sphinx.util.inspect causes circular import problem

View File

@@ -1237,7 +1237,11 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
params = list(sig.parameters.values())
if params[0].annotation is Parameter.empty:
params[0] = params[0].replace(annotation=typ)
func.__signature__ = sig.replace(parameters=params) # type: ignore
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
except TypeError:
# failed to update signature (ex. built-in or extension types)
return
class SingledispatchFunctionDocumenter(FunctionDocumenter):
@@ -1833,7 +1837,11 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
params = list(sig.parameters.values())
if params[1].annotation is Parameter.empty:
params[1] = params[1].replace(annotation=typ)
func.__signature__ = sig.replace(parameters=params) # type: ignore
try:
func.__signature__ = sig.replace(parameters=params) # type: ignore
except TypeError:
# failed to update signature (ex. built-in or extension types)
return
class SingledispatchMethodDocumenter(MethodDocumenter):