diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-12-15 22:40:46 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-15 22:40:46 +0900 |
commit | 415ebc15c59e8b2e7fd2eb1df76017a331f8b131 (patch) | |
tree | 5934d437249ff312ed5d0fe157d800752fbf796f /sphinx/util/inspect.py | |
parent | 4d933716b8074eabfa78093bf271908c6d0bc6e6 (diff) | |
parent | 77e0139a26a080e5b7c0292ebd08fbb2eb540be9 (diff) | |
download | sphinx-git-415ebc15c59e8b2e7fd2eb1df76017a331f8b131.tar.gz |
Merge pull request #5784 from tk0miya/refactor_hack_for_py2
Refactor hack for py2
Diffstat (limited to 'sphinx/util/inspect.py')
-rw-r--r-- | sphinx/util/inspect.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 603fa88ae..d5d2c330b 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -16,9 +16,11 @@ import inspect import re import sys import typing +import warnings from functools import partial from io import StringIO +from sphinx.deprecation import RemovedInSphinx30Warning from sphinx.util import logging from sphinx.util.pycompat import NoneType @@ -128,11 +130,8 @@ def isclassmethod(obj): """Check if the object is classmethod.""" if isinstance(obj, classmethod): return True - elif inspect.ismethod(obj): - if getattr(obj, 'im_self', None): # py2 - return True - elif getattr(obj, '__self__', None): # py3 - return True + elif inspect.ismethod(obj) and obj.__self__ is not None: + return True return False @@ -288,6 +287,9 @@ class Parameter: self.default = default self.annotation = self.empty + warnings.warn('sphinx.util.inspect.Parameter is deprecated.', + RemovedInSphinx30Warning, stacklevel=2) + class Signature: """The Signature object represents the call signature of a callable object and |