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

Mypy should report errors when bpo-33346 would occur #14256

Open
jhance opened this issue Dec 5, 2022 · 2 comments
Open

Mypy should report errors when bpo-33346 would occur #14256

jhance opened this issue Dec 5, 2022 · 2 comments
Labels
feature topic-async async, await, asyncio

Comments

@jhance
Copy link
Collaborator

jhance commented Dec 5, 2022

https://bugs.python.org/issue33346 details some cases where you would get

SyntaxError: asynchronous comprehension outside of an asynchronous function

in some versions of Python, but mypy doesn't complain about these cases. Arguably this isn't necessarily specific to type checking, but it would be nice to report an error if Python is going to give a syntax error (even though it parses!)

I'm not quite sure what version of Python the fix (python/cpython@054e9c8) is in, but it would be nice to give an error message like "await cannot be used in dict comprehensions" in older versions of Python - especially because the error Python gives at runtime is not so good and doesn't include a line number, which gives a subpar experience trying to fix it - something mypy could provide a solution for.

@jhance jhance added the feature label Dec 5, 2022
@AlexWaygood AlexWaygood added the topic-async async, await, asyncio label Dec 5, 2022
@JelleZijlstra
Copy link
Member

The fix is in 3.11 and up (you can see the list of tags that the commit is included in on the GH commit page).

@erictraut
Copy link

This seems like something that would be more appropriate for a linter, since it's not related to type checking. It's also pretty esoteric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-async async, await, asyncio
Projects
None yet
Development

No branches or pull requests

4 participants