[ty] Update SpecializationBuilder hook to get both lower/upper bounds#23848
[ty] Update SpecializationBuilder hook to get both lower/upper bounds#23848
SpecializationBuilder hook to get both lower/upper bounds#23848Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 85.05%. The percentage of expected errors that received a diagnostic held steady at 78.05%. The number of fully passing files held steady at 63/132. |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
flake8
trio
|
bdbe546 to
38c8dc4
Compare
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
2 | 6 | 64 |
type-assertion-failure |
13 | 9 | 9 |
no-matching-overload |
16 | 0 | 0 |
invalid-assignment |
5 | 0 | 4 |
invalid-return-type |
1 | 0 | 1 |
| Total | 37 | 15 | 78 |
Merging this PR will degrade performance by 19.79%
Performance Changes
Comparing Footnotes
|
|
Looking at some selected ecosystem results:
|
|
|
|
The codspeed regression, and 25× perf regression in |
This is a refactoring in support of astral-sh/ty#2799. The eventual goal is to use a
ConstraintSetto hold the pending specialization being built inSpecializationBuilder. That will automatically cause us to combine mappings with union or intersection as appropriate.This PR removes several methods from the
SpecializationBuilderAPI:mappedis removed in favor of a newbuild_withthat applies the mapping while constructing the specialization. The callback is updated to receive the typevar's lower/upper bound from (eventually) the constraint set solution. (For now, we just give it both types from the pending hash map.)infer_reverseand friends are removed in favor of constructing a constraint set directly viawhen_constraint_set_assignable_to. The reverse inference was used to apply our inference logic with the formal/actual reversed. Constraint set assignability handles that just fine.type_mappingsandinto_type_mappingsare also removed. These were used to consume the resut of theinfer_reversecalls. We can replace that by consuming the constraint set created by the assignability check. This requires asolutionswrapper that takes in a similar hook callback as above.