pak.util.inspection

Utilities for expanding upon the standard inspect module.

subclasses(parent_class)

Gets the recursive subclasses of a type.

Parameters:

parent_class (type) – The type to get the subclasses of.

Returns:

The recursive subclasses of parent_class.

Return type:

frozenset

bind_annotations(func_or_signature, /, *args, **kwargs)

Maps function arguments to their annotations.

Parameters:
  • func_or_signature (function or inspect.Signature) –

    If a function, then the annotations are obtained from its signature.

    If an inspect.Signature, then the annotations are obtained from it.

  • *args – The arguments to map annotations to.

  • **kwargs – The arguments to map annotations to.

Returns:

  • args_annotations (list) – The annotations for *args, of the form [(value, annotation)].

  • kwargs_annotations (dict) – The annotations for **kwargs, of the form {name: (value, annotation)}.