from typing import Callable
from typing import Any
import inspect


async def maybe_coroutine(function: Callable, *args, **kwargs) -> Any:
    """
    |coro|

    Returns the return value of the function.

    :param Callable function: The function to call.
    :param args: The arguments.
    :param kwargs: The key arguments:
    :return: The value.
    :rtype: Any
    """

    value = function(*args, **kwargs)

    if inspect.isawaitable(value):
        return await value

    return value