black/tests/data/async_as_identifier.py
Benjamin Woodruff f8617f975d
Add support for always tokenizing async/await as keywords
Fixes #593

I looked into this bug with @ambv and @carljm, and we reached the
conclusion was that it's not possible for the tokenizer to determine if
async/await is a keyword inside all possible generators without breaking
the grammar for older versions of Python.

Instead, we introduce a new tokenizer mode for Python 3.7+ that will
cause all async/await instances to get parsed as a reserved keyword,
which should fix async/await inside generators.
2019-05-09 17:59:29 +02:00

50 lines
495 B
Python

def async():
pass
def await():
pass
await = lambda: None
async = lambda: None
async()
await()
def sync_fn():
await = lambda: None
async = lambda: None
async()
await()
async def async_fn():
await async_fn()
# output
def async():
pass
def await():
pass
await = lambda: None
async = lambda: None
async()
await()
def sync_fn():
await = lambda: None
async = lambda: None
async()
await()
async def async_fn():
await async_fn()