type_utils#
Helpers for type introspection and type-checking.
Functions#
Assertion for statically checking exhaustive pattern matches. |
|
Return the Python type of the non- |
|
Returns the types that are considered immutable by the privacy framework. |
- assert_never(x)#
Assertion for statically checking exhaustive pattern matches.
From https://github.com/python/mypy/issues/5818.
- Parameters
x (NoReturn) –
- Return type
NoReturn
- get_element_type(l, allow_none=True)#
Return the Python type of the non-
None
elements of a list.If the given list is empty or contains elements with multiple types, raises ValueError.
If
allow_none
is true (the default),None
values in the list are ignored; if the list contains onlyNone
values,NoneType
is returned. Ifallow_none
is false, raises ValueError if any element of the list isNone
.
- get_immutable_types()#
Returns the types that are considered immutable by the privacy framework.
While many of these types are technically mutable in python, we assume that users do not mutate their state after creating them or passing them to another object.
- Return type
Tuple[Type, Ellipsis]