ruff/crates
Dhruv Manilawala ef4108af2a
[ty] Generate the top and bottom materialization of a type (#18594)
## Summary

This is to support https://github.com/astral-sh/ruff/pull/18607.

This PR adds support for generating the top materialization (or upper
bound materialization) and the bottom materialization (or lower bound
materialization) of a type. This is the most general and the most
specific form of the type which is fully static, respectively.
    
More concretely, `T'`, the top materialization of `T`, is the type `T`
with all occurrences
of dynamic type (`Any`, `Unknown`, `@Todo`) replaced as follows:

- In covariant position, it's replaced with `object`
- In contravariant position, it's replaced with `Never`
- In invariant position, it's replaced with an unresolved type variable

(For an invariant position, it should actually be replaced with an
existential type, but this is not currently representable in our type
system, so we use an unresolved type variable for now instead.)

The bottom materialization is implemented in the same way, except we
start out in "contravariant" position.

## Test Plan

Add test cases for various types.
2025-06-12 12:06:16 +05:30
..
ruff [ty] Track the origin of the environment.python setting for better error messages (#18483) 2025-06-06 13:36:41 +01:00
ruff_annotate_snippets Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_benchmark [ty] Add --config-file CLI arg (#18083) 2025-05-27 08:00:38 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db Update pre-commit dependencies (#18581) 2025-06-09 08:08:17 +02:00
ruff_dev Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
ruff_diagnostics Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_formatter Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_graph [ty] Fix --python argument for Windows, and improve error messages for bad --python arguments (#18457) 2025-06-05 08:19:15 +01:00
ruff_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_linter [flake8-return] Fix RET504 autofix generating a syntax error (#18428) 2025-06-11 13:38:42 +00:00
ruff_macros Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
ruff_notebook Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_python_ast SourceOrderVisitor should visit the Identifier part of the PatternKeyword node (#18635) 2025-06-12 08:20:14 +02:00
ruff_python_ast_integration_tests SourceOrderVisitor should visit the Identifier part of the PatternKeyword node (#18635) 2025-06-12 08:20:14 +02:00
ruff_python_codegen Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
ruff_python_formatter Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
ruff_python_resolver Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_semantic Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
ruff_python_stdlib Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_trivia Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_server Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
ruff_source_file Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_text_size Add rustfmt.toml file (#18197) 2025-05-19 11:40:58 -04:00
ruff_wasm Bump 0.11.13 (#18484) 2025-06-05 15:18:38 -05:00
ruff_workspace Remove Message::to_rule (#18447) 2025-06-05 12:48:29 -04:00
ty [ty] Update mypy_primer doc (#18638) 2025-06-11 20:50:37 -07:00
ty_ide [ty] Improve support for object.<CURSOR> completions 2025-06-11 14:31:38 -04:00
ty_project [ty] Infer the Python version from --python=<system installation> on Unix (#18550) 2025-06-11 14:32:33 +00:00
ty_python_semantic [ty] Generate the top and bottom materialization of a type (#18594) 2025-06-12 12:06:16 +05:30
ty_server [ty] Fix stale documents on Windows (#18544) 2025-06-09 16:39:11 +02:00
ty_test [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00
ty_vendored [ty] Generate the top and bottom materialization of a type (#18594) 2025-06-12 12:06:16 +05:30
ty_wasm [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00