summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-09-29 16:34:44 -0700
committerJon Dufresne <jon.dufresne@gmail.com>2017-09-30 09:11:06 -0700
commit1711fb429ae4815faa55bc9ccceca59f27f88706 (patch)
tree527cc29c3d5e8ebb80aeb5368ed5cb2876375070 /testsuite
parentc7448b4f8c50904eb71855b6559a9c3650bf510c (diff)
downloadpep8-1711fb429ae4815faa55bc9ccceca59f27f88706.tar.gz
Add W606 warning for async and await keywords in Python 3.7
From https://docs.python.org/3/whatsnew/3.6.html#new-keywords > async and await are not recommended to be used as variable, class, > function or module names. Introduced by PEP 492 in Python 3.5, they > will become proper keywords in Python 3.7. Starting in Python 3.6, the > use of async or await as names will generate a DeprecationWarning. By adding a warning to pycodestyle.py these future warnings and syntax errors can be caught during static code analysis. The await expression tests were taken from PEP-492. https://www.python.org/dev/peps/pep-0492/#id58
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/W60.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/W60.py b/testsuite/W60.py
index cbe267d..030bec5 100644
--- a/testsuite/W60.py
+++ b/testsuite/W60.py
@@ -29,3 +29,48 @@ regex = r'''
\\.png$
'''
s = '\\'
+#: W606
+async = 42
+#: W606
+await = 42
+#: W606
+def async():
+ pass
+#: W606
+def await():
+ pass
+#: W606
+class async:
+ pass
+#: W606
+class await:
+ pass
+#: Okay
+async def read_data(db):
+ data = await db.fetch('SELECT ...')
+#: Okay
+if await fut:
+ pass
+if (await fut):
+ pass
+if await fut + 1:
+ pass
+if (await fut) + 1:
+ pass
+pair = await fut, 'spam'
+pair = (await fut), 'spam'
+with await fut, open():
+ pass
+with (await fut), open():
+ pass
+await foo()['spam'].baz()()
+return await coro()
+return (await coro())
+res = await coro() ** 2
+res = (await coro()) ** 2
+func(a1=await coro(), a2=0)
+func(a1=(await coro()), a2=0)
+await foo() + await bar()
+(await foo()) + (await bar())
+-await foo()
+-(await foo())