Commit Graph

4 Commits

Author SHA1 Message Date
Benjamin Woodruff
448885b256
Move tokenizer config onto grammar, rename flag
Based on the feedback in
https://github.com/python/black/pull/845#issuecomment-490622711

- Remove TokenizerConfig, and add a field to Grammar instead.
- Pass the Grammar to the tokenizer.
- Rename `ASYNC_IS_RESERVED_KEYWORD` to `ASYNC_KEYWORDS` and
  `ASYNC_IS_VALID_IDENTIFIER` to `ASYNC_IDENTIFIERS`.
2019-05-09 17:59:29 +02:00
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
Zsolt Dollenstein
08f1cdd00b
Make sure async for is not broken up to separate lines (#503)
Fixes #372.
2018-09-08 10:34:08 +01:00
Zsolt Dollenstein
883689366c Support parsing of async generators in non-async functions (#165)
This is a new syntax added in python3.7, so black can't verify that reformatting will not change the ast unless black itself is run with 3.7. We'll need to change the error message black gives in this case. @ambv any ideas?

Fixes #125.
2018-08-20 14:47:58 +01:00