py_research.reflect.runtime module#

Utils for reflecting the Python runtime.

get_calling_module(offset=0)[source]#

Return the name of the module calling the current function.

Parameters:

offset (int) –

Return type:

module | None

get_full_args_dict(func, args, kwargs=None)[source]#

Return dict of all args + kwargs.

Parameters:
  • func (Callable) – Function to inspect.

  • args (Sequence) – Positional arguments given to the function.

  • kwargs (dict[str, Any] | None) – Keyword arguments given to the function.

Returns:

Dictionary of all args + kwargs.

Return type:

dict[str, Any]

get_return_type(func)[source]#

Get the return type annotation of given function, if any.

Parameters:

func (Callable) –

Return type:

type | None

get_all_subclasses(cls)[source]#

Return all subclasses of given class.

Parameters:

cls (type[T]) –

Return type:

set[type[T]]