File size: 501 Bytes
a06facb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import inspect

try:
    from contextlib import (  # noqa: F401 lgtm[py/unused-import]
        asynccontextmanager,
    )
except ImportError:
    from async_generator import (  # noqa: F401 E501, lgtm[py/unused-import]
        asynccontextmanager,
    )


async def resolve_awaitable(obj):
    if inspect.isawaitable(obj):
        return await obj

    return obj


async def async_any(items):
    for item in items:
        if await resolve_awaitable(item):
            return True

    return False