[ty] Fix the inferred MRO of functional namedtuple classes#22722
Merged
AlexWaygood merged 2 commits intomainfrom Jan 19, 2026
Merged
[ty] Fix the inferred MRO of functional namedtuple classes#22722AlexWaygood merged 2 commits intomainfrom
AlexWaygood merged 2 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
Member
|
We'll need to fix the false positives on prefect before merging. |
Member
|
Sorry that was a joke. |
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.
Summary
This is a bugfix PR pulled out of #22718. It fixes an issue in #22327 that I missed during review of that PR.
Currently for a class constructed as follows:
we infer that class's MRO as being
(<class 'Point'>, <class 'tuple[Any, Any]'>, <class 'object'>). That's actually the MRO thatPointwill have at runtime (which is maybe why I didn't spot the bug before), but it's not the MRO we should infer, because typeshed pretends thattuplehas a much richer MRO than it does at runtime: typeshed (for very good reasons) says thattupleinherits fromSequence. Our current MRO inference for functional namedtuples is inconsistent with the MRO we'd infer for a class-basedNamedTuple, inconsistent with the MRO we infer for thetupleclass itself, and means that we don't currently consider functionalnamedtupleclasses to be subtypes ofSequence(but they are!).This PR fixes those issues.
Test Plan
mdtests updated and extended