Skip to content

Commit

Permalink
Merge pull request #7823 from tk0miya/7821_overload_builtin_function
Browse files Browse the repository at this point in the history
Fix #7821: autodoc: TypeError is raised for overloaded C-ext function
  • Loading branch information
tk0miya authored Jun 14, 2020
2 parents 46f79c5 + 7c358ed commit 6eb43ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,11 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
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):
Expand Down Expand Up @@ -1833,7 +1837,11 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None:
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):
Expand Down

0 comments on commit 6eb43ba

Please sign in to comment.