-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 def syntax should be rejected if python version < 3.5 #2401
Labels
Comments
Michael0x2a
added a commit
to Michael0x2a/typed_ast
that referenced
this issue
Jun 12, 2017
Python 3.5 introduced three new forms of syntax: - Coroutines with async/await (PEP 492) - The '@' operator (PEP 465) - Additional unpacking generalizations (PEP 448) This commit adds a version check for the first two, but not the last item. This commit was originally motivated by python/mypy#2401. I decided to also add a check for '@' because it looked like an easy fix, but didn't add a check for the unpacking generalizations because that seemed harder.
ddfisher
pushed a commit
to python/typed_ast
that referenced
this issue
Jun 13, 2017
…#41) Python 3.5 introduced three new forms of syntax: - Coroutines with async/await (PEP 492) - The '@' operator (PEP 465) - Additional unpacking generalizations (PEP 448) This commit adds a version check for the first two, but not the last item. This commit was originally motivated by python/mypy#2401. I decided to also add a check for the '@' operator because it looked like an easy fix, but didn't add a check for the unpacking generalizations because that seemed harder. The checks for `async for`, `async with`, and `await` are probably unnecessary because they can only be used inside `async def` anyways, which will always be checked first, but I figured I might as well add them just in case. I can remove them if you want, though, since it probably does incur a slight performance hit.
This issue should be fixed by python/typed_ast#41 (assuming that typed_ast publishes a new release and mypy updates its requirements info before it also releases, etc). FWIW, after making this change, I wasn't able to trigger the crash by making Awaitable and friends conditional. That said, I also didn't test this very thoroughly, so take that with a grain of salt. |
This already works correctly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code using
async def
should not be allowed to type-check when a Python version less than 3.5 is selected.Moreover, there are several types in typeshed that should only be defined for Python versions >= 3.5, e.g. Awaitable; but if I make those conditional in typeshed/stdlib/3/typing.pyi, mypy actually crashes on
async def
functions.The text was updated successfully, but these errors were encountered: