ruff/crates/red_knot_python_semantic
Alex Waygood a3f3d734a1
[red-knot] Ban list literals in most contexts in type expressions (#16847)
## Summary

This PR reworks `TypeInferenceBuilder::infer_type_expression()` so that
we emit diagnostics when encountering a list literal in a type
expression. The only place where a list literal is allowed in a type
expression is if it appears as the first argument to `Callable[]`, and
`Callable` is already heavily special-cased in our type-expression
parsing.

In order to ensure that list literals are _always_ allowed as the
_first_ argument to `Callabler` (but never allowed as the second, third,
etc. argument), I had to do some refactoring of our type-expression
parsing for `Callable` annotations.

## Test Plan

New mdtests added, and existing ones updated
2025-03-19 14:42:42 +00:00
..
resources [red-knot] Ban list literals in most contexts in type expressions (#16847) 2025-03-19 14:42:42 +00:00
src [red-knot] Ban list literals in most contexts in type expressions (#16847) 2025-03-19 14:42:42 +00:00
tests red_knot_test: add support for diagnostic snapshotting 2025-02-05 13:02:54 -05:00
build.rs Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
Cargo.toml [red-knot] Add a test to ensure that KnownClass::try_from_file_and_name() is kept up to date (#16326) 2025-02-24 12:14:20 +00:00
mdtest.py [red-knot] Fix possible TOCTOU mistake in mdtest runner (#15673) 2025-01-22 15:24:25 +00:00
mdtest.py.lock [red-knot] Markdown test runner (#15632) 2025-01-21 14:06:35 +01:00