summaryrefslogtreecommitdiff
path: root/tests/functional/a/await_outside_async.py
blob: 2bc1267615a4e80e99da01f5bbca183e8b3345f8 (plain)
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
27
28
29
30
# pylint: disable=missing-docstring,unused-variable
import asyncio

async def nested():
    return 42

async def main():
    nested()
    print(await nested())  # This is okay

def not_async():
    print(await nested())  # [await-outside-async]


async def func(i):
    return i**2

async def okay_function():
    var = [await func(i) for i in range(5)]  # This should be okay


# Test nested functions
async def func2():
    def inner_func():
        await asyncio.sleep(1)  # [await-outside-async]


def outer_func():
    async def inner_func():
        await asyncio.sleep(1)