symforce.typing_util module¶
General python typing-related utilities
- get_type(a)[source]¶
Returns the type of the element if its an instance, or a pass through if already a type.
- scalar_like(a)[source]¶
Returns whether the element is scalar-like (an int, float, or sympy expression).
This method does not rely on the value of a, only the type.
- maybe_tuples_of_types_from_annotation(annotation, return_annotation_if_not_tuple=False)[source]¶
Attempt to construct a tuple of types from an annotation of the form
T.Tuple[A, B, C]
of any fixed length, recursively.If this is not possible, because the annotation is not a
T.Tuple
, returns:The annotation itself, if
return_annotation_if_not_tuple
is TrueNone
, otherwise
If the annotation is a
T.Tuple
, but is of unknown length, returnsNone