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 python/mypy#5818.
- Parameters:
x (NoReturn)
- Return type:
NoReturn
- get_element_type(l, allow_none=True)#
Return the Python type of the non-
Noneelements of a list.If the given list is empty or contains elements with multiple types, raises ValueError.
If
allow_noneis true (the default),Nonevalues in the list are ignored; if the list contains onlyNonevalues,NoneTypeis returned. Ifallow_noneis 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]