Type Utils
Type Utils
These are common utilities for types. They perform casting in the signature and check that the cast is valid.
extra_types.type_utils
strict_cast(typ, expr)
Determine whether an object is of a given type at runtime.
This method is currently very limited in its ability to express types;
as a result, it will produce false-positives, such as with Literal types.
If the type does not match, this raises a TypeError.
Source code in extra_types/type_utils.py
strict_not_none(expr)
Check that an expression is not None.
If it is None, this raises a TypeError.