Skip to content

Black can't parse new Python 3.7 async generator syntax #593

@DRMacIver

Description

@DRMacIver

Operating system: Linux but unlikely to be OS specific
Python version: 3.7.1
Black version: 18.9b0
Does also happen on master: Yes (as of 32eed7d)

The following code (extracted from test_asyncgen.py in CPython) is currently not handled by black:

def make_arange(n):
    # This syntax is legal starting with Python 3.7
    return (i * 2 for i in range(n) if await wrap(i))

Running black on it results in:

error: cannot format test_asyncgen.py: Cannot parse: 3:45:     return (i * 2 for i in range(n) if await wrap(i))
All done! 💥 💔 💥
1 file failed to reformat.

As per the comment, this is new Python 3.7 syntax, so presumably "just" a case of needing to update the parser to reflect the grammar change.

Metadata

Metadata

Assignees

Labels

T: bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions