diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-09 15:51:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 15:51:22 (GMT) |
commit | 507a574de31a1bd7fed8ba4f04afa285d985109b (patch) | |
tree | 44fb249533ae98698ef7736bc050df450f9a07e1 /Doc | |
parent | 150af7543214e1541fa582374502ac1cd70e8eb4 (diff) | |
download | cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.zip cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.tar.gz cpython-507a574de31a1bd7fed8ba4f04afa285d985109b.tar.bz2 |
bpo-43682: @staticmethod inherits attributes (GH-25268)
Static methods (@staticmethod) and class methods (@classmethod) now
inherit the method attributes (__module__, __name__, __qualname__,
__doc__, __annotations__) and have a new __wrapped__ attribute.
Changes:
* Add a repr() method to staticmethod and classmethod types.
* Add tests on the @classmethod decorator.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 10 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 5cb1df9..dca8b93 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -269,6 +269,11 @@ are always available. They are listed here in alphabetical order. Class methods can now wrap other :term:`descriptors <descriptor>` such as :func:`property`. + .. versionchanged:: 3.10 + Class methods now inherit the method attributes (``__module__``, + ``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and + have a new ``__wrapped__`` attribute. + .. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) Compile the *source* into a code or AST object. Code objects can be executed @@ -1632,6 +1637,11 @@ are always available. They are listed here in alphabetical order. For more information on static methods, see :ref:`types`. + .. versionchanged:: 3.10 + Static methods now inherit the method attributes (``__module__``, + ``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and + have a new ``__wrapped__`` attribute. + .. index:: single: string; str() (built-in function) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index d690463..7cf5576 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -617,6 +617,12 @@ Other Language Changes respectively. (Contributed by Joshua Bronson, Daniel Pope, and Justin Wang in :issue:`31861`.) +* Static methods (:func:`@staticmethod <staticmethod>`) and class methods + (:func:`@classmethod <classmethod>`) now inherit the method attributes + (``__module__``, ``__name__``, ``__qualname__``, ``__doc__``, + ``__annotations__``) and have a new ``__wrapped__`` attribute. + (Contributed by Victor Stinner in :issue:`43682`.) + New Modules =========== |