mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7797 from tk0miya/7791_TypeError_for_singledispatchfunction
Fix #7791: autodoc: TypeError is raised on documenting singledispatch function
This commit is contained in:
commit
23a51a3a33
1
CHANGES
1
CHANGES
@ -123,6 +123,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
|
||||
|
@ -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."""
|
||||
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
|
||||
|
||||
@ -1811,7 +1819,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."""
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user