]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115775: Add whatsnew entry about __static_attributes__ (GH-117909)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Fri, 19 Apr 2024 10:57:31 +0000 (11:57 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2024 10:57:31 +0000 (12:57 +0200)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Doc/library/stdtypes.rst
Doc/reference/datamodel.rst
Doc/whatsnew/3.13.rst

index fc613d4dbe1b5cd76b2447c0472ab76b3a2435cc..6c13bd015d5691f5c611db6f9e6661a1c4eea816 100644 (file)
@@ -5542,6 +5542,13 @@ types, where they are relevant.  Some of these are not reported by the
       [<class 'bool'>, <enum 'IntEnum'>, <flag 'IntFlag'>, <class 're._constants._NamedIntConstant'>]
 
 
+.. attribute:: class.__static_attributes__
+
+      A tuple containing names of attributes of this class which are accessed
+      through ``self.X`` from any function in its body.
+
+      .. versionadded:: 3.13
+
 .. _int_max_str_digits:
 
 Integer string conversion length limitation
index 6d6395a21f65d2720eec764fb242b1260e826200..5e1558362ffaa0365f2ba4cf4140c7ece3ba8172 100644 (file)
@@ -970,6 +970,7 @@ A class object can be called (see above) to yield a class instance (see below).
    single: __doc__ (class attribute)
    single: __annotations__ (class attribute)
    single: __type_params__ (class attribute)
+   single: __static_attributes__ (class attribute)
 
 Special attributes:
 
@@ -1000,6 +1001,10 @@ Special attributes:
       A tuple containing the :ref:`type parameters <type-params>` of
       a :ref:`generic class <generic-classes>`.
 
+   :attr:`~class.__static_attributes__`
+      A tuple containing names of attributes of this class which are accessed
+      through ``self.X`` from any function in its body.
+
 
 Class instances
 ---------------
index 0ea27a081b2d2df23be8774a953edb744fd1fee3..cf9853f94872c31659f66302d181f81b4fb3b97a 100644 (file)
@@ -115,6 +115,11 @@ Improved Error Messages
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
     TypeError: split() got an unexpected keyword argument 'max_split'. Did you mean 'maxsplit'?
 
+* Classes have a new :attr:`~class.__static_attributes__` attribute, populated by the compiler,
+  with a tuple of names of attributes of this class which are accessed
+  through ``self.X`` from any function in its body. (Contributed by Irit Katriel
+  in :gh:`115775`.)
+
 Incremental Garbage Collection
 ------------------------------