Skip to content

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

Open
robsdedude wants to merge 6 commits intopython:mainfrom
robsdedude:fix-issue-99505
Open

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

Conversation

@robsdedude
Copy link
Contributor

@robsdedude robsdedude commented Aug 26, 2024

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
Copy link

ghost commented Aug 26, 2024

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
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
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.

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

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

2 participants