Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async and await can't be used as identifiers in 3.6 #83

Closed
bgw opened this issue Aug 19, 2019 · 1 comment
Closed

Async and await can't be used as identifiers in 3.6 #83

bgw opened this issue Aug 19, 2019 · 1 comment

Comments

@bgw
Copy link
Contributor

bgw commented Aug 19, 2019

It looks like parso's tokenizer unconditionally treats async and await as keywords under 3.6. However, while that's valid on 3.7+, on 3.6 it's conditionally treated as a keyword or identifier depending on if you're inside an async function.

Black has some logic to support this behavior when parsing as <3.7: https://github.com/psf/black/blob/40e8b3a231bade22d838858435a33d60a8325306/blib2to3/pgen2/tokenize.py#L359

This was reported by @zhammer on Instagram/LibCST#32

It might not be worth supporting because it's an older version of Python, and the hacks required to support it are pretty ugly, but I figured I'd upstream this issue.

@davidhalter
Copy link
Owner

I think I had some discussions about this before. Not sure if it was in this issue tracker, but we ended up with the current solution for these reasons:

  1. Using async/await as an identifier will be a syntax error in the future, so people should fix it now
  2. The complexity was just not worth the benefit.
  3. It's quite a bit of work. Especially because parso supports error recovery and finding all the edge cases where the tokenizer might fail is annoying.

So if you don't mind, I would close this. In a bit more than two years 3.6 will be end of life and there's a good chance that we'll drop support anyway.

I personally won't do the work, there are more important things to do. But if you want to do this, I would consider accepting a patch. It's definitely possible.

@bgw bgw closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants