mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
## Summary This PR adds more features to #16468. * Adds a new error rule `invalid-type-checking-constant`, which occurs when we try to assign a value other than `False` to a user-defined `TYPE_CHECKING` variable (it is possible to assign `...` in a stub file). * Allows annotated assignment to `TYPE_CHECKING`. Only types that `False` can be assigned to are allowed. However, the type of `TYPE_CHECKING` will be inferred to be `Literal[True]` regardless of what the type is specified. ## Test plan I ran the tests with `cargo test -p red_knot_python_semantic` and confirmed that all tests passed. --------- Co-authored-by: Carl Meyer <carl@astral.sh>