From 826e2dd07e18c6cb6056cdffd8eeca5d10f2362b Mon Sep 17 00:00:00 2001 From: Tan Long Date: Thu, 19 Feb 2026 02:04:17 +0800 Subject: [PATCH 1/2] docs: correct DynamicClassAttribute type from function to class --- Doc/library/types.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 01f4df3c89091f1..d5e79c09fc19dc7 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -507,7 +507,7 @@ Additional Utility Classes and Functions .. versionchanged:: 3.13 Added support for an optional positional argument. -.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None) +.. class:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None) Route attribute access on a class to __getattr__. From 07a4a66de36df0b4bcc9e7901a6890a06a531cc3 Mon Sep 17 00:00:00 2001 From: Tan Long Date: Wed, 18 Nov 2026 16:06:05 +0800 Subject: [PATCH 2/2] Add sphinx rolenames --- Doc/library/types.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index d8310e7ab57c7b6..7a6e7aa3fae6a57 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -517,12 +517,12 @@ Additional Utility Classes and Functions .. class:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None) - Route attribute access on a class to __getattr__. + Route attribute access on a class to :meth:`~object.__getattr__`. This is a descriptor, used to define attributes that act differently when accessed through an instance and through a class. Instance access remains normal, but access to an attribute through a class will be routed to the - class's __getattr__ method; this is done by raising AttributeError. + class's ``__getattr__`` method; this is done by raising :exc:`AttributeError`. This allows one to have properties active on an instance, and have virtual attributes on the class with the same name (see :class:`enum.Enum` for an example).