ruff/crates
Carl Meyer 17dc2e4d80
[ty] don't assume that deferred type inference means deferred name resolution (#20160)
## Summary

We have the ability to defer type inference of some parts of
definitions, so as to allow us to create a type that may need to be
recursively referenced in those other parts of the definition.

We also have the ability to do type inference in a context where all
name resolution should be deferred (that is, names should be looked up
from all-reachable-definitions rather than from the location of use.)
This is used for all annotations in stubs, or if `from __future__ import
annotations` is active.

Previous to this PR, these two concepts were linked: deferred-inference
always implied deferred-name-resolution, though we also supported
deferred-name-resolution without deferred-inference, via
`DeferredExpressionState`.

For the upcoming `typing.TypeAlias` support, I will defer inference of
the entire RHS of the alias (so as to support cycles), but that doesn't
imply deferred name resolution; at runtime, the RHS of a name annotated
as `typing.TypeAlias` is executed eagerly.

So this PR fully de-couples the two concepts, instead explicitly setting
the `DeferredExpressionState` in those cases where we should defer name
resolution.

It also fixes a long-standing related bug, where we were deferring name
resolution of all names in class bases, if any of the class bases
contained a stringified annotation.

## Test Plan

Added test that failed before this PR.
2025-08-29 16:19:45 -07:00
..
ruff Show fixes by default (#19919) 2025-08-29 09:53:05 -04:00
ruff_annotate_snippets Move full diagnostic rendering to ruff_db (#19415) 2025-08-08 12:56:23 -04:00
ruff_benchmark [ty] Benchmarks for problematic implicit instance attributes cases (#20133) 2025-08-28 15:25:25 +02:00
ruff_cache
ruff_db Show fixes by default (#19919) 2025-08-29 09:53:05 -04:00
ruff_dev [ty] Remove duplicate global lint registry (#20053) 2025-08-22 19:43:12 -04:00
ruff_diagnostics Fix rust feature activation (#20012) 2025-08-21 09:26:06 +02:00
ruff_formatter Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_graph [ty] Remove KnownModule::is_enum (#19681) 2025-08-01 10:31:12 +02:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Less confidently mark f-strings as empty when inferring truthiness (#20152) 2025-08-29 22:12:54 +00:00
ruff_macros Don't cache files with diagnostics (#19869) 2025-08-12 15:28:44 -04:00
ruff_memory_usage [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
ruff_notebook Improve diff rendering for notebooks (#20036) 2025-08-25 09:20:42 -04:00
ruff_options_metadata Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_ast Less confidently mark f-strings as empty when inferring truthiness (#20152) 2025-08-29 22:12:54 +00:00
ruff_python_ast_integration_tests Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_codegen Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_formatter [ty] Shrink size of AstNodeRef (#20028) 2025-08-22 17:03:22 -04:00
ruff_python_index
ruff_python_literal
ruff_python_parser [ty] Shrink size of AstNodeRef (#20028) 2025-08-22 17:03:22 -04:00
ruff_python_semantic Add a ScopeKind for the __class__ cell (#20048) 2025-08-26 09:49:08 -04:00
ruff_python_stdlib
ruff_python_trivia [ruff] Preserve relative whitespace in multi-line expressions (RUF033) (#19647) 2025-08-27 19:15:44 +00:00
ruff_python_trivia_integration_tests
ruff_server Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_source_file Move diff rendering to ruff_db (#20006) 2025-08-21 09:47:00 -04:00
ruff_text_size [ty] Fix a few more diagnostic differences from Ruff (#19806) 2025-08-08 11:31:19 -04:00
ruff_wasm Bump 0.12.11 (#20136) 2025-08-28 09:45:01 -04:00
ruff_workspace Fix rust feature activation (#20012) 2025-08-21 09:26:06 +02:00
ty [ty] Better error message for attempting to assign to a read-only property (#20150) 2025-08-29 13:22:23 +00:00
ty_combine [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_ide [ty] Refactor inlay hints structure to use separate parts (#20052) 2025-08-26 10:21:31 +05:30
ty_project [ty] Remove duplicate global lint registry (#20053) 2025-08-22 19:43:12 -04:00
ty_python_semantic [ty] don't assume that deferred type inference means deferred name resolution (#20160) 2025-08-29 16:19:45 -07:00
ty_server [ty] Refactor inlay hints structure to use separate parts (#20052) 2025-08-26 10:21:31 +05:30
ty_static [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_test Fix mdtest ignore python code blocks (#20139) 2025-08-28 09:59:03 -07:00
ty_vendored [ty] Sync vendored typeshed stubs (#20083) 2025-08-25 17:01:51 +00:00
ty_wasm [ty] Refactor inlay hints structure to use separate parts (#20052) 2025-08-26 10:21:31 +05:30