ruff/crates/ty_vendored
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
..
src Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
ty_extensions [ty] Generate the top and bottom materialization of a type (#18594) 2025-06-12 12:06:16 +05:30
vendor/typeshed Sync vendored typeshed stubs (#18407) 2025-06-01 15:21:18 +01:00
.gitignore Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
build.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
Cargo.toml Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
README.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00

Vendored types for the stdlib

This crate vendors typeshed's stubs for the standard library. The vendored stubs can be found in crates/ty_vendored/vendor/typeshed. The file crates/ty_vendored/vendor/typeshed/source_commit.txt tells you the typeshed commit that our vendored stdlib stubs currently correspond to.

The typeshed stubs are updated every two weeks via an automated PR using the sync_typeshed.yaml workflow in the .github/workflows directory. This workflow can also be triggered at any time via workflow dispatch.