Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 945fff4

Browse files
committed
Issue 20438: Add a note about deprecating old inspect APIs to whatsnew.
Also, deprecate formatargspec, formatargvalues, and getargvalues functions. Since we are deprecating 'getfullargspec' function in 3.5 (documentation only, no DeprecationWarning), it makes sense to also deprecate functions designed to be directly used with it. In 3.6 we will remove 'getargsspec' function (was deprecated since Python 3.0), and start raising DeprecationWarnings in other 'getarg*' family of functions. We can remove them in 3.7 or later. Also, it is worth noting, that Signature API does not provide 100% of functionality that deprecated APIs have. It is important to do a soft deprecation of outdated APIs in 3.5 to gather users feedback, and improve Signature object.
1 parent c8386f7 commit 945fff4

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

Doc/library/inspect.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,10 @@ Classes and functions
793793
*n* elements listed in *args*.
794794

795795
.. deprecated:: 3.0
796-
Use :func:`getfullargspec` instead, which provides information about
797-
keyword-only arguments and annotations.
796+
Use :func:`signature` and
797+
:ref:`Signature Object <inspect-signature-object>`, which provide a
798+
better introspecting API for callables. This function will be removed
799+
in Python 3.6.
798800

799801

800802
.. function:: getfullargspec(func)
@@ -834,6 +836,11 @@ Classes and functions
834836
are the names of the ``*`` and ``**`` arguments or ``None``. *locals* is the
835837
locals dictionary of the given frame.
836838

839+
.. deprecated:: 3.5
840+
Use :func:`signature` and
841+
:ref:`Signature Object <inspect-signature-object>`, which provide a
842+
better introspecting API for callables.
843+
837844

838845
.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations[, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]])
839846

@@ -856,13 +863,23 @@ Classes and functions
856863
>>> formatargspec(*getfullargspec(f))
857864
'(a: int, b: float)'
858865

866+
.. deprecated:: 3.5
867+
Use :func:`signature` and
868+
:ref:`Signature Object <inspect-signature-object>`, which provide a
869+
better introspecting API for callables.
870+
859871

860872
.. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue])
861873

862874
Format a pretty argument spec from the four values returned by
863875
:func:`getargvalues`. The format\* arguments are the corresponding optional
864876
formatting functions that are called to turn names and values into strings.
865877

878+
.. deprecated:: 3.5
879+
Use :func:`signature` and
880+
:ref:`Signature Object <inspect-signature-object>`, which provide a
881+
better introspecting API for callables.
882+
866883

867884
.. function:: getmro(cls)
868885

Doc/whatsnew/3.5.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,16 @@ Deprecated Python modules, functions and methods
815815
:meth:`inspect.Signature.from_callable` instead. (Contributed by Yury
816816
Selivanov in :issue:`24248`.)
817817

818+
* :func:`inspect.getargspec` is deprecated and scheduled to be removed in
819+
Python 3.6. (See :issue:`20438` for details.)
820+
821+
* :func:`~inspect.getfullargspec`, :func:`~inspect.getargvalues`,
822+
:func:`~inspect.getcallargs`, :func:`~inspect.getargvalues`,
823+
:func:`~inspect.formatargspec`, and :func:`~inspect.formatargvalues` are
824+
deprecated in favor of :func:`inspect.signature` API. (See :issue:`20438`
825+
for details.)
826+
827+
818828
Deprecated functions and types of the C API
819829
-------------------------------------------
820830

0 commit comments

Comments
 (0)