Files
David Peter 1d40d153a9 [ty] Document runtime support in ty-extensions (#30497)
## 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.
2026-11-17 14:41:58 +00:00

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.