gh-99505: Fix docs for determining the metaclass#123349
Open
robsdedude wants to merge 6 commits intopython:mainfrom
Open
gh-99505: Fix docs for determining the metaclass#123349robsdedude wants to merge 6 commits intopython:mainfrom
robsdedude wants to merge 6 commits intopython:mainfrom
Conversation
merwok
reviewed
Feb 13, 2026
| * 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; |
Member
There was a problem hiding this comment.
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…
Contributor
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternatively, this could be less explicit but more prose by adding something along the lines of
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/