[ty] Avoid duplicated work during multi-inference#23923
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdowntrio
flake8
sphinx
prefect
|
|
Merging this PR will not alter performance
Comparing Footnotes
|
|
| @@ -4993,11 +4992,8 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> { | |||
| MultiInferenceState::Ignore, | |||
There was a problem hiding this comment.
Is this correct after the changes in this PR? Doesn't this mean that when we .extend() below, if speculative inference succeeded, we still won't get the expression types, causing Unknown hover results on some argument expressions?
I'm able to reproduce that with this example code:
from typing import TypeVar
T = TypeVar("T")
def list1(x: T) -> list[T]:
return [x]
def f() -> list[int] | list[str]:
return list1(1 + 2)we lose hover expression types on 1 + 2 with this PR. We should probably add this as a hover test?
Is this new speculative-inference usable in all cases where we currently use MultiInferenceState? Could it replace it entirely?
There was a problem hiding this comment.
Is this new speculative-inference usable in all cases where we currently use MultiInferenceState? Could it replace it entirely?
I think so, and I hope that to be the result of these incremental refactors. MultiInferenceState::Ignore is a little ugly in that it breaks the interal invariant of that all expression types are stored for a given inference.
* main: (94 commits) Fix shell injection via `shell=True` in subprocess calls (#23894) [ty] Refactor `relation.rs` to store state on a struct rather than passing around 7 arguments every time we recurse (#23837) Don't return code actions for non-Python documents (#23905) [ty] Make the default database truly statically infallible (#23929) [ty] Add `Download` button to ty playground which creates a zip export (#23478) [ty] Respect `kw_only` overwrites in dataclasses (#23930) [ty] Clarify in diagnostics that `from __future__ import annotations` only stringifies type annotations (#23928) [ty] Add a `Copy Markdown` button to playground (#23002) [ty] Fix folding range classification of lines starting with `#` (#23831) [ty] Fix folding ranges for notebooks (#23830) [ty] fix too-many-cycle panics when inferring literal type loop variables (#23875) Add `RegularCallableTypeOf` and `into_regular_callable` in `ty_extensions` (#23909) [ty] treat properties as full structural types (#23925) [ty] Avoid duplicated work during multi-inference (#23923) [ty]: make `possibly-missing-attribute` ignored by default [ty]: split out `possibly-missing-submodule` from `possibly-missing-attribute` Update astral-sh/setup-uv action to v7.5.0 (#23922) [ty] Show truthiness in ConstraintSet display and simplify falsy error message (#23913) Bump 0.15.6 (#23919) [ty] Narrow type context during collection literal inference (#23844) ...
Instead of ignoring intermediate inference results, we can create a temporary
TypeInferenceBuilderand merge the chosen inference results into the current region. This should hopefully reclaim some of the performance regressions introduced by #23844 and #21210.