[ty] Track argument variance for literal promotion without relying on SpecializationBuilder internals#21905
[ty] Track argument variance for literal promotion without relying on SpecializationBuilder internals#21905
SpecializationBuilder internals#21905Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
|
Code looks fine. Ecosystem changes on zulip suggest that there's an unintentional behavior change here? |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
21 | 0 | 7 |
unused-ignore-comment |
0 | 3 | 0 |
| Total | 21 | 3 | 7 |
|
It seems like in the zulip cases we are failing to do literal promotion in a case where previously we did promote. |
Fixed the zulip case and added an mdtest regression for it. |
CodSpeed Performance ReportMerging #21905 will degrade performances by 4.25%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
Looks like both the ecosystem CI jobs timed out, which I think is probably not related to the github outage? |
Yep, I've got a mypy_primer run going locally to confirm |
* origin/main: (29 commits) Document range suppressions, reorganize suppression docs (#21884) Ignore ruff:isort like ruff:noqa in new suppressions (#21922) [ty] Handle `Definition`s in `SemanticModel::scope` (#21919) [ty] Attach salsa db when running ide tests for easier debugging (#21917) [ty] Don't show hover for expressions with no inferred type (#21924) [ty] avoid unions of generic aliases of the same class in fixpoint (#21909) [ty] Squash false positive logs for failing to find `builtins` as a real module [ty] Uniformly use "not supported" in diagnostics (#21916) [ty] Reduce size of ty-ide snapshots (#21915) [ty] Adjust scope completions to use all reachable symbols [ty] Rename `all_members_of_scope` to `all_end_of_scope_members` [ty] Remove `all_` prefix from some routines on UseDefMap Enable `--document-private-items` for `ruff_python_formatter` (#21903) Remove `BackwardsTokenizer` based `parenthesized_range` references in `ruff_linter` (#21836) [ty] Revert "Do not infer types for invalid binary expressions in annotations" (#21914) Skip over trivia tokens after re-lexing (#21895) [ty] Avoid inferring types for invalid binary expressions in string annotations (#21911) [ty] Improve overload call resolution tracing (#21913) [ty] fix missing heap_size on Salsa query (#21912) [ty] Support implicit type of `cls` in signatures (#21771) ...
df40a2b to
438de79
Compare
Cherry-picked several of performance optimizations commits from #21551 and that seems to have fixed the timeouts. Locally, at least! Waiting for CI to confirm |
Welp, famous last words! Instead of pushing this forward more, I'm going to see if I can update the generic protocol PR to not require this. |
This happened, so I'm closing this for now |
When inferring a specialization for a generic function call, we might want to promote
Literaltypes that appear in the inferred specialization. Whether we do so depends (among other things) on the variance of those typevars in the parameter types that each argument is matched to. That means we need to track the variance of each typevar as we process the arguments during inference.Before, we were piggy-backing on how
SpecializationBuilderwalks through the formal and actual types. Itsinfer_mapmethod takes in a callback that is invoked each time we record a new type mapping for a typevar. Before, this method was provided with the variance of that typevar, according to the formal/actual pair that we just checked.We are in the process of changing the internals of
SpecializationBuilderso that this approach is no longer tenable. This PR updates the call inference logic to calculate the typevar variance separately, without making any assumptions about howSpecializationBuilderdoes its work.