[ty] Split equality from other comparison inference#26370
Open
charliermarsh wants to merge 3 commits into
Open
[ty] Split equality from other comparison inference#26370charliermarsh wants to merge 3 commits into
charliermarsh wants to merge 3 commits into
Conversation
11023c6 to
8c8c117
Compare
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.19%. The number of fully passing files held steady at 95/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
flake8
trio
prefect
|
|
ddfb082 to
c072fb1
Compare
c072fb1 to
60d8110
Compare
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
#26337 routes definite
==and!=results through the shared equality evaluator before falling back to normal expression inference. When that evaluator returns ambiguous truthiness, however, we still run the full comparison dispatcher, repeating literal, tuple, and constraint-set work just to distinguish a builtinboolresult from an arbitrary custom comparison return type.This splits the top-level dispatch between equality and the other comparison operators. Equality evaluation now distinguishes definite truthiness, ambiguous builtin
bool, and comparisons whose result type still needs to be inferred. Known builtin comparisons can stop after the shared evaluator, while custom comparisons continue through structural dispatch and the existing dunder fallback. The remaining literal dispatch uses a narrower non-equality operator enum, so it no longer duplicates the==and!=cases.To make the shared path complete, this also moves constraint-set equality and builtin tuple equality into the equality evaluator. Fixed-length tuples compare their elements using equality semantics even for an outer
!=, while uncertain element results still fall back to expression inference so custom return types and bool-conversion diagnostics are preserved. Regression coverage verifies that equality and inequality over union arms retain each custom dunder return type.