mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 09:52:18 +00:00
![]() Extend red-knot type inference to cover all syntax, so that inferring types for a scope gives all expressions a type. This means we can run the red-knot semantic lint on all Python code without panics. It also means we can infer types for `builtins.pyi` without panics. To keep things simple, this PR intentionally doesn't add any new type inference capabilities: the expanded coverage is all achieved with `Type::Unknown`. But this puts the skeleton in place for adding better inference of all these language features. I also had to add basic Salsa cycle recovery (with just `Type::Unknown` for now), because some `builtins.pyi` definitions are cyclic. To test this, I added a comprehensive corpus of test snippets sourced from Cinder under [MIT license](https://github.com/facebookincubator/cinder/blob/cinder/3.10/cinderx/LICENSE), which matches Ruff's license. I also added to this corpus some additional snippets for newer language features: all the `27_func_generic_*` and `73_class_generic_*` files, as well as `20_lambda_default_arg.py`, and added a test which runs semantic-lint over all these files. (The test doesn't assert the test-corpus files are lint-free; just that they are able to lint without a panic.) |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |