https://github.com/python/cpython/commit/41dec4158d880a3fd200a84683521fe4ea618992
commit: 41dec4158d880a3fd200a84683521fe4ea618992
branch: main
author: Pablo Galindo Salgado <pablog...@gmail.com>
committer: pablogsal <pablog...@gmail.com>
date: 2025-04-23T14:27:53+01:00
summary:

gh-132449: Add whatsnew entry for typos in keywords (#132838)

files:
M Doc/whatsnew/3.14.rst

diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index 63a5bab7fe8fea..0f73b0e73195ee 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -264,6 +264,49 @@ is unchanged.
 Improved error messages
 -----------------------
 
+* The interpreter now provides helpful suggestions when it detects typos in 
Python
+  keywords. When a word that closely resembles a Python keyword is encountered,
+  the interpreter will suggest the correct keyword in the error message. This
+  feature helps programmers quickly identify and fix common typing mistakes. 
For
+  example:
+
+  .. code-block:: python
+
+     >>> whille True:
+     ...     pass
+     Traceback (most recent call last):
+       File "<stdin>", line 1
+         whille True:
+         ^^^^^^
+     SyntaxError: invalid syntax. Did you mean 'while'?
+
+     >>> asynch def fetch_data():
+     ...     pass
+     Traceback (most recent call last):
+       File "<stdin>", line 1
+         asynch def fetch_data():
+         ^^^^^^
+     SyntaxError: invalid syntax. Did you mean 'async'?
+
+     >>> async def foo():
+     ...     awaid fetch_data()
+     Traceback (most recent call last):
+       File "<stdin>", line 2
+         awaid fetch_data()
+         ^^^^^
+     SyntaxError: invalid syntax. Did you mean 'await'?
+
+     >>> raisee ValueError("Error")
+     Traceback (most recent call last):
+       File "<stdin>", line 1
+         raisee ValueError("Error")
+         ^^^^^^
+     SyntaxError: invalid syntax. Did you mean 'raise'?
+
+  While the feature focuses on the most common cases, some variations of
+  misspellings may still result in regular syntax errors.
+  (Contributed by Pablo Galindo in :gh:`132449`.)
+
 * When unpacking assignment fails due to incorrect number of variables, the
   error message prints the received number of values in more cases than before.
   (Contributed by Tushar Sadhwani in :gh:`122239`.)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to