|
102 | 102 |
|
103 | 103 | PyCF_ONLY_AST = 1024
|
104 | 104 | SINGLETONS = frozenset(['False', 'None', 'True'])
|
105 |
| -KEYWORDS = frozenset(keyword.kwlist + ['print', 'async']) - SINGLETONS |
| 105 | +KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS |
106 | 106 | UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
|
107 | 107 | ARITHMETIC_OP = frozenset(['**', '*', '/', '//', '+', '-', '@'])
|
108 | 108 | WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
|
@@ -493,7 +493,6 @@ def missing_whitespace_after_keyword(logical_line, tokens):
|
493 | 493 | if (tok0.end == tok1.start and
|
494 | 494 | keyword.iskeyword(tok0.string) and
|
495 | 495 | tok0.string not in SINGLETONS and
|
496 |
| - tok0.string not in ('async', 'await') and |
497 | 496 | not (tok0.string == 'except' and tok1.string == '*') and
|
498 | 497 | not (tok0.string == 'yield' and tok1.string == ')') and
|
499 | 498 | tok1.string not in ':\n'):
|
@@ -1645,76 +1644,6 @@ def python_3000_invalid_escape_sequence(logical_line, tokens, noqa):
|
1645 | 1644 | pos = string.find('\\', pos + 1)
|
1646 | 1645 |
|
1647 | 1646 |
|
1648 |
| -@register_check |
1649 |
| -def python_3000_async_await_keywords(logical_line, tokens): |
1650 |
| - """'async' and 'await' are reserved keywords starting at Python 3.7. |
1651 |
| -
|
1652 |
| - W606: async = 42 |
1653 |
| - W606: await = 42 |
1654 |
| - Okay: async def read(db):\n data = await db.fetch('SELECT ...') |
1655 |
| - """ |
1656 |
| - # The Python tokenize library before Python 3.5 recognizes |
1657 |
| - # async/await as a NAME token. Therefore, use a state machine to |
1658 |
| - # look for the possible async/await constructs as defined by the |
1659 |
| - # Python grammar: |
1660 |
| - # https://docs.python.org/3/reference/grammar.html |
1661 |
| - |
1662 |
| - state = None |
1663 |
| - for token_type, text, start, end, line in tokens: |
1664 |
| - error = False |
1665 |
| - |
1666 |
| - if token_type == tokenize.NL: |
1667 |
| - continue |
1668 |
| - |
1669 |
| - if state is None: |
1670 |
| - if token_type == tokenize.NAME: |
1671 |
| - if text == 'async': |
1672 |
| - state = ('async_stmt', start) |
1673 |
| - elif text == 'await': |
1674 |
| - state = ('await', start) |
1675 |
| - elif (token_type == tokenize.NAME and |
1676 |
| - text in ('def', 'for')): |
1677 |
| - state = ('define', start) |
1678 |
| - |
1679 |
| - elif state[0] == 'async_stmt': |
1680 |
| - if token_type == tokenize.NAME and text in ('def', 'with', 'for'): |
1681 |
| - # One of funcdef, with_stmt, or for_stmt. Return to |
1682 |
| - # looking for async/await names. |
1683 |
| - state = None |
1684 |
| - else: |
1685 |
| - error = True |
1686 |
| - elif state[0] == 'await': |
1687 |
| - if token_type == tokenize.NAME: |
1688 |
| - # An await expression. Return to looking for async/await |
1689 |
| - # names. |
1690 |
| - state = None |
1691 |
| - elif token_type == tokenize.OP and text == '(': |
1692 |
| - state = None |
1693 |
| - else: |
1694 |
| - error = True |
1695 |
| - elif state[0] == 'define': |
1696 |
| - if token_type == tokenize.NAME and text in ('async', 'await'): |
1697 |
| - error = True |
1698 |
| - else: |
1699 |
| - state = None |
1700 |
| - |
1701 |
| - if error: |
1702 |
| - yield ( |
1703 |
| - state[1], |
1704 |
| - "W606 'async' and 'await' are reserved keywords starting with " |
1705 |
| - "Python 3.7", |
1706 |
| - ) |
1707 |
| - state = None |
1708 |
| - |
1709 |
| - # Last token |
1710 |
| - if state is not None: |
1711 |
| - yield ( |
1712 |
| - state[1], |
1713 |
| - "W606 'async' and 'await' are reserved keywords starting with " |
1714 |
| - "Python 3.7", |
1715 |
| - ) |
1716 |
| - |
1717 |
| - |
1718 | 1647 | ########################################################################
|
1719 | 1648 | @register_check
|
1720 | 1649 | def maximum_doc_length(logical_line, max_doc_length, noqa, tokens):
|
|
0 commit comments