Extend operator-typo SyntaxError suggestions (`=<`, `=>`, `=!`) to `if/while` other conditions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Follow-up #151375
In that PR we added helpful SyntaxError messages for common operator typos: =< suggests <=, => suggests >=, and =! suggests !=.
These suggestions currently only work when the typo appears in a plain statement. like
'a => b' invalid syntax. Maybe you meant '>=' instead of '=>'?
So this is for extending in if, while, or other conditions:
These only fire for bare statements, so
if a => b:still gives the generic error, no? That is probably fine for a first iteration (the= <tokenization makes it look like an assignment), but maybe we should add a test documenting it or a follow-up issue for theif/whilecase.
Originally posted by @pablogsal in https://github.com/python/cpython/pull/151375#discussion_r3683730462
I'm planning to work on this and submit a PR shortly after the follow up merged, please avoid PR in this
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading PR #151375 and its existing SyntaxError suggestion implementation to understand how the operator typos are detected for bare statements. Extend the behavior to the if, while, and other condition cases, then add or update tests covering those forms and verify the suggested messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100