https://github.com/python/cpython/commit/6194a552f2b010e1dcdd006996f613c956520124
commit: 6194a552f2b010e1dcdd006996f613c956520124
branch: main
author: Savannah Ostrowski <[email protected]>
committer: savannahostrowski <[email protected]>
date: 2026-02-23T17:25:05Z
summary:

Update argparse `suggest_on_error` code snippet in docs (#144985)

files:
M Doc/library/argparse.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index ebcf8bf4dac002..ca4f439c345f32 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -602,18 +602,13 @@ choices (if specified) or subparser names, along with a 
"maybe you meant"
 suggestion if a close match is found. Note that this only applies for arguments
 when the choices specified are strings::
 
-   >>> parser = argparse.ArgumentParser(description='Process some integers.',
-                                        suggest_on_error=True)
-   >>> parser.add_argument('--action', choices=['sum', 'max'])
-   >>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
-   ...                     help='an integer for the accumulator')
-   >>> parser.parse_args(['--action', 'sumn', 1, 2, 3])
-   tester.py: error: argument --action: invalid choice: 'sumn', maybe you 
meant 'sum'? (choose from 'sum', 'max')
-
-You can disable suggestions by setting ``suggest_on_error`` to ``False``::
+   >>> parser = argparse.ArgumentParser(suggest_on_error=True)
+   >>> parser.add_argument('--action', choices=['debug', 'dryrun'])
+   >>> parser.parse_args(['--action', 'debugg'])
+   usage: tester.py [-h] [--action {debug,dryrun}]
+   tester.py: error: argument --action: invalid choice: 'debugg', maybe you 
meant 'debug'? (choose from debug, dryrun)
 
-   >>> parser = argparse.ArgumentParser(description='Process some integers.',
-                                        suggest_on_error=False)
+You can disable suggestions by setting ``suggest_on_error`` to ``False``.
 
 .. versionadded:: 3.14
 .. versionchanged:: 3.15

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to