Various snippets of Python code I use enough to justify it

Stringifying an exception Link to heading
TimedCache Link to heading

The latest version of the timed cache exists here.

Given how widely it’s used I should just make it a standalone package.

maybe_coro Link to heading
async def maybe_coro(func: MaybeCoro, *args, **kwargs):
    """Call the given func, awaiting if required."""
    if asyncio.iscoroutinefunction(func):
        return await func(*args, **kwargs)

    return func(*args, **kwargs)