import inspect


async def to_awaitable(value):
    """Wraps a value in a coroutine.
    If value is a future, it will await it. Otherwise it will simply return the value.
    Useful when we have a mix of coroutines and regular functions.

    >>> run_sync(await to_awaitable(5))
    '5'
    >>> run_sync(await to_awaitable(some_coroutine_that_returns_its_input(5)))
    '5'
    """
    if inspect.isawaitable(value):
        return await value
    return value