summaryrefslogtreecommitdiff
path: root/pycodestyle.py
diff options
context:
space:
mode:
authorTony Wang <wwwjfy@gmail.com>2018-11-24 22:41:17 +0800
committerTony Wang <wwwjfy@gmail.com>2018-11-24 23:15:44 +0800
commit2a7629f18f7a27bb2ef4b70db7a7b57e730db8de (patch)
tree6543b7ba7fcf19307669ca5ef1c28d340c7dd02d /pycodestyle.py
parent3d37ea0aa2e369852c98bbbcaef8a89ed00996dc (diff)
downloadpep8-2a7629f18f7a27bb2ef4b70db7a7b57e730db8de.tar.gz
fix #811, corner cases for async/await check
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-xpycodestyle.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index c9e1667..18a16ca 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -1566,12 +1566,19 @@ def python_3000_async_await_keywords(logical_line, tokens):
for token_type, text, start, end, line in tokens:
error = False
+ if token_type == tokenize.NL:
+ continue
+
if state is None:
if token_type == tokenize.NAME:
if text == 'async':
state = ('async_stmt', start)
elif text == 'await':
state = ('await', start)
+ elif (token_type == tokenize.NAME and
+ text in ('def', 'for')):
+ state = ('define', start)
+
elif state[0] == 'async_stmt':
if token_type == tokenize.NAME and text in ('def', 'with', 'for'):
# One of funcdef, with_stmt, or for_stmt. Return to
@@ -1584,8 +1591,15 @@ def python_3000_async_await_keywords(logical_line, tokens):
# An await expression. Return to looking for async/await
# names.
state = None
+ elif token_type == tokenize.OP and text == '(':
+ state = None
else:
error = True
+ elif state[0] == 'define':
+ if token_type == tokenize.NAME and text in ('async', 'await'):
+ error = True
+ else:
+ state = None
if error:
yield (