Closed
Description
Currently, when users make typos in Python keywords, they receive generic "invalid syntax" error messages without any helpful suggestions about what might be wrong. This creates a frustrating experience, especially for beginners who might not immediately recognize that they've misspelled a keyword.
For example, typing whille True:
instead of while True:
would currently result in a generic syntax error without any hint that the problem is a misspelled keyword.
I propose to start raising errors like these:
==================================================
Traceback (most recent call last):
File "/home/pablogsal/github/python/main/check.py", line 18, in test_mistyped_program
exec(code_example)
~~~~^^^^^^^^^^^^^^
File "<string>", line 2
asynch def fetch_data():
^^^^^^
SyntaxError: invalid syntax. Did you mean 'async'?
==================================================
Traceback (most recent call last):
File "/home/pablogsal/github/python/main/check.py", line 18, in test_mistyped_program
exec(code_example)
~~~~^^^^^^^^^^^^^^
File "<string>", line 6
result = awaid fetch_data()
^^^^^
SyntaxError: invalid syntax. Did you mean 'await'?
==================================================
finally:
Traceback (most recent call last):
File "/home/pablogsal/github/python/main/check.py", line 18, in test_mistyped_program
exec(code_example)
~~~~^^^^^^^^^^^^^^
File "<string>", line 6
finaly:
^^^^^^
SyntaxError: invalid syntax. Did you mean 'finally'?
==================================================
Traceback (most recent call last):
File "/home/pablogsal/github/python/main/check.py", line 18, in test_mistyped_program
exec(code_example)
~~~~^^^^^^^^^^^^^^
File "<string>", line 4
raisee ValueError("Value cannot be negative")
^^^^^^
SyntaxError: invalid syntax. Did you mean 'raise'?
==================================================
Linked PRs
Metadata
Metadata
Assignees
Labels
(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)A feature request or enhancementA feature request or enhancement