Repository navigation
fix: preserve MRO order in Class._bases when __orig_bases__ is present - #909
Open
abhishekrajv7-cmd wants to merge 1 commit into
Open
abhishekrajv7-cmd wants to merge 1 commit into
abhishekrajv7-cmd wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #903
Cause
Class._basespreviously placedisinstance(base, type)entries from__orig_bases__beforeself.obj.__mro__. When a class inherits from both a concrete base class and a typing construct (such asclass Stuff(Base, Iterable):),__orig_bases__containsBase, puttingBaseahead ofStuffin_bases. As a result,_declarationsand_member_objectsattributedStuff.__init__(and other overridden members) toBase.Changes
Class._basesinpdoc/doc.pyto placeself.obj(mro[0]) first, followed by anytypeentries from__orig_bases__not already inmro(e.g.TypedDictbases on Python >= 3.12), followed bymro[1:], deduplicated withdict.fromkeys.test_bases_mro_order_with_orig_basesintest/test_doc.pycovering overridden__init__, indirect MRO ordering with__orig_bases__, andTypedDictfield overrides.test/testdata/typed_dict.txtwhereBarandBaznow list their own attributes before inherited ones.Verification
ruff check .ruff format --check pdoc/doc.py test/test_doc.pymypy pdoc testpytest --cov=pdoc --cov-report term-missing -m "not slow"(153 passed, 2 skipped on Python 3.13.14; 100% coverage onpdoc/doc.py)