mirror of
https://github.com/python/cpython.git
synced 2025-11-19 10:46:17 +00:00
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.
This commit is contained in:
parent
150af75432
commit
507a574de3
8 changed files with 133 additions and 22 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
===========
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue