mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-22 11:09:19 +08:00
## Summary The `ty-extensions` package lets Python evaluate and inspect `Intersection[A, B]` and `Not[A]` at runtime. Update the stub docstrings and the `experimental-syntax` documentation to point readers to the package.
640 B
640 B
What it does
Makes sure that the argument of static_assert is statically known to be true.
Why is this bad?
A static_assert call represents an explicit request from the user for the type checker to emit an
error if the argument cannot be verified to evaluate to True in a boolean context.
Examples
from ty_extensions import static_assert
# evaluates to `False`
static_assert(1 + 1 == 3) # error
# does not have a statically known truthiness
static_assert(int(2.0 * 3.0) == 6) # error
Note that running this example would require the
ty-extensions package.