Skip to content

gh-99505: Fix docs for determining the metaclass#123349

Open
robsdedude wants to merge 8 commits into
python:mainfrom
robsdedude:fix-issue-99505
Open

gh-99505: Fix docs for determining the metaclass#123349
robsdedude wants to merge 8 commits into
python:mainfrom
robsdedude:fix-issue-99505

Conversation

@robsdedude

@robsdedude robsdedude commented Aug 26, 2024

Copy link
Copy Markdown
Contributor

Alternatively, this could be less explicit but more prose by adding something along the lines of

Further, must the metaclass always be valid when removing any number of
right-most bases.

to the paragraph about the TypeError. However, I find it really hard to wrap my head around the rules if they're written in prose like that as the metaclass selection process is not necessarily super straight forward.

Closes #99505


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

@ghost

ghost commented Aug 26, 2024

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

* if an explicit metaclass is given and it is an instance of :func:`type`,
then it is used as candidate;
* if bases are defined but no explicit metaclass, the metaclass of the first
base is used as candidate;

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.

Technically it would be the class (or type) of the first base (itself a class), not its metaclass, but not sure how to phrase that elegantly…

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.

Thanks, a good point. I would've interpreted "the metaclass of a class C" as type(C) and not the technically correct type(type(C)). I think "class of the first base" and similar is better here. It's more accurate and still comprehensible, I find.

@github-actions

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 Apr 18, 2026
Comment thread Doc/reference/datamodel.rst Outdated
Comment thread Doc/reference/datamodel.rst Outdated
@read-the-docs-community

read-the-docs-community Bot commented Jun 9, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33063168 | 📁 Comparing 0ceb57f against main (7053bbd)

  🔍 Preview build  

1 file changed
± reference/datamodel.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Resolution / determining of metaclass docs don't align with what really happens

3 participants