bpo-43797: Improve syntax error for invalid comparisons#25317
bpo-43797: Improve syntax error for invalid comparisons#25317pablogsal merged 4 commits intopython:masterfrom
Conversation
a36abe8 to
8d7971c
Compare
527808d to
e23664c
Compare
gvanrossum
left a comment
There was a problem hiding this comment.
This inspired me to point out a whole lotta nits with the phrasing of the errors. But basically I think this is an improvement, so if you don't feel like fixing all those, that's fine with me. (Maybe check with Serhiy again.)
Lib/test/test_generators.py
Outdated
| Traceback (most recent call last): | ||
| ... | ||
| SyntaxError: cannot assign to yield expression | ||
| SyntaxError: cannot assign to yield expression. Maybe you meant '==' instead of '='? |
There was a problem hiding this comment.
Here and elsewhere it feels jarring that the initial sentence ("cannot ...") doesn't start with a capital letter, but is followed by a period and another sentence that does.
There was a problem hiding this comment.
Ok, I can update the error message with a capital letter.
There was a problem hiding this comment.
Actually, on second thought, the capital letter technically is the "S" in SyntaxError no?
| Traceback (most recent call last): | ||
| ... | ||
| SyntaxError: invalid syntax | ||
| SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='? |
There was a problem hiding this comment.
I'm not sure the suggestion here is very useful. More likely some other misunderstanding or typo happened.
There was a problem hiding this comment.
In this particular example yes, but imagine something like all(x = y for x in elements for y in other_elements). As it makes more sense depending on the actual function, is going to be hard to contextualize.
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
gvanrossum
left a comment
There was a problem hiding this comment.
Thanks! I agree on your pushback.
|
@pablogsal: Please replace |
https://bugs.python.org/issue43797