File: _helpers.py

package info (click to toggle)
python-aiobotocore 2.13.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 832 kB
  • sloc: python: 10,572; makefile: 71
file content (25 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (2)
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
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