Skip to content

Correct DynamicClassAttribute from function to class in types docs - #144968

Merged
encukou merged 5 commits into
python:mainfrom
tanloong:fix-doc-function-to-class
Nov 18, 2026
Merged

encukou merged 5 commits into
python:mainfrom
tanloong:fix-doc-function-to-class

Conversation

@tanloong

@tanloong tanloong commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

The documentation incorrectly labeled DynamicClassAttribute as a function, which misrepresents its actual type.

As this is a documentation change, I didn't add a news entry. I will create an issue if needed.


📚 Documentation preview 📚: https://cpython-previews--144968.org.readthedocs.build/

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 7, 2026
@read-the-docs-community

read-the-docs-community Bot commented May 8, 2026 •

Copy link
Copy Markdown

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 17, 2026
@tanloong

tanloong commented May 30, 2026 •

Copy link
Copy Markdown
Contributor Author

I just noticed that sphinx developers once considered adding the Python objtype checking, but finally decided not to implement it, likely due to the consequent uncomfortable restriction for python developers: sphinx-doc/sphinx#7243

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 30, 2026

@johnslavik johnslavik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread Doc/library/types.rst Outdated
Comment on lines 520 to 528

@johnslavik johnslavik Nov 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if we could generalize this PR to include:

-Route attribute access on a class to __getattr__.
+Route attribute access on a class to :func:`~object.__getattr__`.
(...)
-class's __getattr__ method; this is done by raising AttributeError.
+class's ``__getattr__`` method; this is done by raising :exc:`AttributeError`.
(...)

@tanloong tanloong Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review! I've added the requested change, but switched :func: to :meth: for object.__getattr__, which is documented as .. method:: in Doc/reference/datamodel.rst. And search under Doc/ shows :meth: is more often used than :func: ( 100 vs 5 ) for object.__xxx__. Those :func:`object.__xxx__` s do work though, I think due to that sphinx refers python objects even if objtype not matched (sphinx-doc/sphinx#7243).

@encukou
encukou merged commit b219e55 into python:main Nov 18, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Nov 18, 2026
@encukou encukou added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 18, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @tanloong for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @tanloong for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Nov 18, 2026

Copy link
Copy Markdown

GH-162204 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 18, 2026
@bedevere-app

bedevere-app Bot commented Nov 18, 2026

Copy link
Copy Markdown

GH-162205 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 18, 2026
@tanloong
tanloong deleted the fix-doc-function-to-class branch November 18, 2026 11:36
encukou pushed a commit that referenced this pull request Nov 18, 2026
…s docs (GH-144968) (GH-162205)

Also: add sphinx roles to the text

(cherry picked from commit b219e55)

Co-authored-by: Tan Long <tanloong@foxmail.com>
encukou pushed a commit that referenced this pull request Nov 18, 2026
…s docs (GH-144968) (GH-162204)

Also: add sphinx roles to the text

(cherry picked from commit b219e55)

Co-authored-by: Tan Long <tanloong@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news stale Stale PR or inactive for long period of time. topic-typing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants