-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
crash with generator in list comprehension #10189
Comments
This is a syntax error in 3.8 and later, presumably because it has no useful behavior: https://docs.python.org/3.10/whatsnew/3.8.html#changes-in-python-behavior. Perhaps mypy should just produce an error for it in any Python version. |
Hey! I'm relatively new to Open Source Contribution, Is there anything I could be helpful for!😃 |
It is indeed reported as a syntax error in 3.8 and later when compiling, but not when only building the AST, preventing mypy from catching the error before processing the graph. The following raises
The following raises no exception.
|
Good point! We should definitely catch this in mypy then. This should be a relatively easy thing to do for a new contributor. |
I can have a try! Out of curiosity, should we regard the latter (that is, ast.parse does not raise |
Great, thanks!
I don't think so; there's a bunch of other things that are caught only after the ast is constructed and Fortunately mypy doesn't crash on that one:
|
Ok, thanks! |
I just opened the PR #12048. My fix is quite concise. Maybe too much? (I may have missed something.) Also, please let me know if my PR doesn't meet the repo's standards. |
Fixes #10189 Produce an error when encountering a yield expression (both `yield` and `yield from` clauses) in comprehensions and generator expressions. The latter is a syntax error in python 3.8+; see #10189 and also [python issue 10544](https://bugs.python.org/issue10544).
Crash Report
possibly related to #10188
Traceback
To Reproduce
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: