summaryrefslogtreecommitdiff
path: root/sphinx/util/inspect.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-08 17:40:13 +0900
committerGitHub <noreply@github.com>2020-11-08 17:40:13 +0900
commit896ecc34d7b36f3d31cd38e77bb0849ae8ad41bb (patch)
treee530bce7c41e0a4afffc84f0b7f15f2ee8d924d0 /sphinx/util/inspect.py
parent9f0f34cbdae4125a7e868e57a29930104ce6f5a8 (diff)
parenta163bbe870dc5bc7f3863ead37cd391be81fb0cc (diff)
downloadsphinx-git-896ecc34d7b36f3d31cd38e77bb0849ae8ad41bb.tar.gz
Merge branch '3.x' into 8119_control_appearance_of_member_not_in_module.__all__
Diffstat (limited to 'sphinx/util/inspect.py')
-rw-r--r--sphinx/util/inspect.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index f2cd8070b..27f478675 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -62,14 +62,6 @@ def getargspec(func: Callable) -> Any:
methods."""
warnings.warn('sphinx.ext.inspect.getargspec() is deprecated',
RemovedInSphinx50Warning, stacklevel=2)
- # On 3.5+, signature(int) or similar raises ValueError. On 3.4, it
- # succeeds with a bogus signature. We want a TypeError uniformly, to
- # match historical behavior.
- if (isinstance(func, type) and
- is_builtin_class_method(func, "__new__") and
- is_builtin_class_method(func, "__init__")):
- raise TypeError(
- "can't compute signature for built-in type {}".format(func))
sig = inspect.signature(func)
@@ -439,14 +431,20 @@ def _should_unwrap(subject: Callable) -> bool:
return False
-def signature(subject: Callable, bound_method: bool = False, follow_wrapped: bool = False,
+def signature(subject: Callable, bound_method: bool = False, follow_wrapped: bool = None,
type_aliases: Dict = {}) -> inspect.Signature:
"""Return a Signature object for the given *subject*.
:param bound_method: Specify *subject* is a bound method or not
:param follow_wrapped: Same as ``inspect.signature()``.
- Defaults to ``False`` (get a signature of *subject*).
"""
+
+ if follow_wrapped is None:
+ follow_wrapped = True
+ else:
+ warnings.warn('The follow_wrapped argument of sphinx.util.inspect.signature() is '
+ 'deprecated', RemovedInSphinx50Warning, stacklevel=2)
+
try:
try:
if _should_unwrap(subject):