get_annotations_from_signature¶
-
utilipy.utils.inspect.
get_annotations_from_signature
(signature: inspect.Signature) → Dict[str, Any][source]¶ Get annotations from Signature object.
- Parameters
- signature: Signature
the object’s signature
- Returns
- annotations: dict
argument {name: annotation} values return annotations under key ‘return’
Examples
>>> def func(x: 'x annotation') -> 'return annotation': ... pass >>> sig = Signature.from_callable(func) >>> get_annotations_from_signature(sig) {'x': 'x annotation', 'return': 'return annotation'}