summaryrefslogtreecommitdiff
path: root/tests/functional/a/await_outside_async.py
diff options
context:
space:
mode:
authoryushao2 <36848472+yushao2@users.noreply.github.com>2021-06-10 04:02:23 +0800
committerGitHub <noreply@github.com>2021-06-09 22:02:23 +0200
commit2a186f4afd3e507c33fa387dfa2d9cfefd795b49 (patch)
tree1d31923a4532555064b7a0f40a503f461019e3fa /tests/functional/a/await_outside_async.py
parent78de5c49a61c8a3f2ca9930956a7df8e8f3ccae0 (diff)
downloadpylint-git-2a186f4afd3e507c33fa387dfa2d9cfefd795b49.tar.gz
Implemented new checker await-outside-async (#4514)
Diffstat (limited to 'tests/functional/a/await_outside_async.py')
-rw-r--r--tests/functional/a/await_outside_async.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/functional/a/await_outside_async.py b/tests/functional/a/await_outside_async.py
new file mode 100644
index 000000000..2bc126761
--- /dev/null
+++ b/tests/functional/a/await_outside_async.py
@@ -0,0 +1,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)