mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-33594: Add deprecation info in inspect.py module (GH-7036)
This commit is contained in:
parent
0f14fc1a7c
commit
ded87d804e
2 changed files with 18 additions and 7 deletions
|
@ -1070,8 +1070,10 @@ def getargspec(func):
|
||||||
Alternatively, use getfullargspec() for an API with a similar namedtuple
|
Alternatively, use getfullargspec() for an API with a similar namedtuple
|
||||||
based interface, but full support for annotations and keyword-only
|
based interface, but full support for annotations and keyword-only
|
||||||
parameters.
|
parameters.
|
||||||
|
|
||||||
|
Deprecated since Python 3.5, use `inspect.getfullargspec()`.
|
||||||
"""
|
"""
|
||||||
warnings.warn("inspect.getargspec() is deprecated, "
|
warnings.warn("inspect.getargspec() is deprecated since Python 3.0, "
|
||||||
"use inspect.signature() or inspect.getfullargspec()",
|
"use inspect.signature() or inspect.getfullargspec()",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
|
args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
|
||||||
|
@ -2797,19 +2799,25 @@ class Signature:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_function(cls, func):
|
def from_function(cls, func):
|
||||||
"""Constructs Signature for the given python function."""
|
"""Constructs Signature for the given python function.
|
||||||
|
|
||||||
warnings.warn("inspect.Signature.from_function() is deprecated, "
|
Deprecated since Python 3.5, use `Signature.from_callable()`.
|
||||||
"use Signature.from_callable()",
|
"""
|
||||||
|
|
||||||
|
warnings.warn("inspect.Signature.from_function() is deprecated since "
|
||||||
|
"Python 3.5, use Signature.from_callable()",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
return _signature_from_function(cls, func)
|
return _signature_from_function(cls, func)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_builtin(cls, func):
|
def from_builtin(cls, func):
|
||||||
"""Constructs Signature for the given builtin function."""
|
"""Constructs Signature for the given builtin function.
|
||||||
|
|
||||||
warnings.warn("inspect.Signature.from_builtin() is deprecated, "
|
Deprecated since Python 3.5, use `Signature.from_callable()`.
|
||||||
"use Signature.from_callable()",
|
"""
|
||||||
|
|
||||||
|
warnings.warn("inspect.Signature.from_builtin() is deprecated since "
|
||||||
|
"Python 3.5, use Signature.from_callable()",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
return _signature_from_builtin(cls, func)
|
return _signature_from_builtin(cls, func)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Document ``getargspec``, ``from_function`` and ``from_builtin`` as
|
||||||
|
deprecated in their respective docstring, and include version since
|
||||||
|
deprecation in DeprecationWarning message.
|
Loading…
Add table
Add a link
Reference in a new issue