Skip to content

Commit b89c874

Browse files
committed
gh-132449: Add whatsnew entry for typos in keywords
1 parent 5f50541 commit b89c874

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,49 @@ is unchanged.
264264
Improved error messages
265265
-----------------------
266266

267+
* The interpreter now provides helpful suggestions when it detects typos in Python
268+
keywords. When a word that closely resembles a Python keyword is encountered,
269+
the interpreter will suggest the correct keyword in the error message. This
270+
feature helps programmers quickly identify and fix common typing mistakes. For
271+
example:
272+
273+
.. code-block:: python
274+
275+
>>> whille True:
276+
... pass
277+
Traceback (most recent call last):
278+
File "<stdin>", line 1
279+
whille True:
280+
^^^^^^
281+
SyntaxError: invalid syntax. Did you mean 'while'?
282+
283+
>>> asynch def fetch_data():
284+
... pass
285+
Traceback (most recent call last):
286+
File "<stdin>", line 1
287+
asynch def fetch_data():
288+
^^^^^^
289+
SyntaxError: invalid syntax. Did you mean 'async'?
290+
291+
>>> async def foo():
292+
... awaid fetch_data()
293+
Traceback (most recent call last):
294+
File "<stdin>", line 2
295+
awaid fetch_data()
296+
^^^^^
297+
SyntaxError: invalid syntax. Did you mean 'await'?
298+
299+
>>> raisee ValueError("Error")
300+
Traceback (most recent call last):
301+
File "<stdin>", line 1
302+
raisee ValueError("Error")
303+
^^^^^^
304+
SyntaxError: invalid syntax. Did you mean 'raise'?
305+
306+
While the feature focuses on the most common cases, some variations of
307+
misspellings may still result in regular syntax errors. (Contributed by Pablo
308+
Galindo in :gh:`132449`.)
309+
267310
* When unpacking assignment fails due to incorrect number of variables, the
268311
error message prints the received number of values in more cases than before.
269312
(Contributed by Tushar Sadhwani in :gh:`122239`.)

0 commit comments

Comments
 (0)