bridge.utils module

bridge.utils module#

Cross-cutting utilities.

async bridge.utils.maybe_await(func, *args, **kwargs)[source]#

Wrap a function/method as an awaitable that may be async or sync, or to return a plain value.

Parameters:
  • func (Callable[..., Any] | Any) – A function/method to call, or a plain value.

  • *args – Positional arguments to pass to the function if func is callable.

  • **kwargs – Keyword arguments to pass to the function if func is callable.

Returns:

The result of calling the function, or the plain value.

Return type:

Any

bridge.utils.require_args(*required)[source]#

Ensure that certain keyword arguments are provided to an async function. Decorator function.

Parameters:

required (str) – Names of required keyword arguments. Can be multiple.