-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
base: main
Are you sure you want to change the base?
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. |
Local testing of positions and code highlight:
assert
does not have=
->==
suggestion #136616