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
gh-111488: Changed error message in case of no 'in' keyword after 'for' in cmp #113656
Conversation
… 'for' in list comprehensions
|
This approach doesn't work. Please read the discussion on the issue, particularly this comment: For example, this PR breaks this case: as it now shows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the discussion on the issue
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
fixed |
|
Hello, I have made the requested changes; please review again :) |
|
This is better but note lowering the grammar to not include expressions will still change existing errors. For example: changes to I think is not too bad because the error is still correct but this may affect other constructs, although I think the error will more or less be correct (maybe it will show AFTER some other real error, though). @lysnikolaou what do you think? |
|
An example of what I mean: will change to here are two errors and now we show the one that's further from the start of the comprehension. So after fixing that there is another error reported BEFORE it. I am not sure if we should care about that, but this is a difference. |
|
(@grigoriev-semyon don't change anything yet, let's check what @lysnikolaou thinks) |
|
I'm okay with both, although I'm incline to say let's fix this one and accept that there might be cases that become suboptimal because of it. Either way we have to accept that there are error messages that are very hard to get right, and this might be one of them. I'm also kind of inclined to try and have a more sophisticated approach to this and other error messages, where you have a priority system where you can try more than one |
|
@pablogsal I tried to improve the result, but it seems difficult. If you agree, I suggest merging this PR and creating a task to further improve the error in this place. |
|
Yeah I think we will merge this and check how it goes. Thanks for the patience @grigoriev-semyon and the good work! |
|
Congrats @grigoriev-semyon! Thanks everyone :) |


Fixes #111488
SyntaxErrormessage forx for x if range(1)#111488