ruff/crates/red_knot_workspace
Carl Meyer 29c36a56b2
[red-knot] fix scope inference with deferred types (#13204)
Test coverage for #13131 wasn't as good as I thought it was, because
although we infer a lot of types in stubs in typeshed, we don't check
typeshed, and therefore we don't do scope-level inference and pull all
types for a scope. So we didn't really have good test coverage for
scope-level inference in a stub. And because of this, I got the code for
supporting that wrong, meaning that if we did scope-level inference with
deferred types, we'd end up never populating the deferred types in the
scope's `TypeInference`, which causes panics like #13160.

Here I both add test coverage by running the corpus tests both as `.py`
and as `.pyi` (which reveals the panic), and I fix the code to support
deferred types in scope inference.

This also revealed a problem with deferred types in generic functions,
which effectively span two scopes. That problem will require a bit more
thought, and I don't want to block this PR on it, so for now I just
don't defer annotations on generic functions.

Fixes #13160.
2024-09-03 11:20:43 -07:00
..
resources/test/corpus [red-knot] Resolve function annotations before adding function symbol (#13084) 2024-08-23 19:31:36 -07:00
src Add a few missing `#[return_ref]` attributes (#13223) 2024-09-03 09:15:43 +02:00
tests [red-knot] fix scope inference with deferred types (#13204) 2024-09-03 11:20:43 -07:00
Cargo.toml [red-knot] fix scope inference with deferred types (#13204) 2024-09-03 11:20:43 -07:00