-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
gh-136616: Improve assert
syntax error messages
#136653
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
Conversation
Grammar/python.gram
Outdated
| 'assert' expression ',' a=expression '=' b=expression { | ||
RAISE_SYNTAX_ERROR_KNOWN_RANGE( | ||
a, b, | ||
"cannot assign to %s here. Maybe you meant '==' instead of '='?", | ||
_PyPegen_get_expr_name(a)) } |
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.
Is the second alternative here needed in reality. If someone's using the second argument here and have a comparison there, maybe they're confused and meant something completely different?
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.
Hm, good question. They might. For example, assert some.method() == other.method(), some == other
might be a realiastic case. But, I am open to other opinions :)
This is a bit annoying. I opened #136680 to fix this. |
@pablogsal @lysnikolaou friendly ping :) |
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.
This looks good to me! I played around a bit with it as well and couldn't find something obviously wrong.
Thanks! I will wait for a week or so for @pablogsal's review. And merge it or address comments and merge it :) |
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.
Let's roll! 🚀
🛼 rolling! Thanks! :) |
Local testing of positions and code highlight:
assert
does not have=
->==
suggestion #136616