ruff/crates/red_knot_python_semantic/src
Carl Meyer 2d3914296d
[red-knot] handle all syntax without panic (#12499)
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.)
2024-07-25 17:38:08 -07:00
..
semantic_index [red-knot] handle all syntax without panic (#12499) 2024-07-25 17:38:08 -07:00
types [red-knot] handle all syntax without panic (#12499) 2024-07-25 17:38:08 -07:00
ast_node_ref.rs [red-knot] per-definition inference, use-def maps (#12269) 2024-07-16 11:02:30 -07:00
builtins.rs [red-knot] Resolve symbols from builtins.pyi in the stdlib if they cannot be found in other scopes (#12390) 2024-07-19 17:44:56 +01:00
db.rs [red-knot] Improved file watching (#12382) 2024-07-23 08:18:59 +02:00
lib.rs [red-knot] Resolve symbols from builtins.pyi in the stdlib if they cannot be found in other scopes (#12390) 2024-07-19 17:44:56 +01:00
node_key.rs [red-knot] Extract red_knot_python_semantic crate (#11926) 2024-06-20 13:24:24 +02:00
semantic_index.rs [red-knot] rename module_global to global (#12385) 2024-07-18 13:05:30 -07:00
semantic_model.rs [red-knot] rename module_global to global (#12385) 2024-07-18 13:05:30 -07:00
types.rs [red-knot] add maybe-undefined lint rule (#12414) 2024-07-22 13:53:59 -07:00