bpo-9694: Fix misleading phrase "optional arguments" (GH-23858)

This commit is contained in:
Raymond Hettinger 2020-12-23 09:40:56 -08:00 committed by GitHub
parent bfda4f5776
commit 41b223d29c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 95 deletions

View File

@ -83,7 +83,7 @@ Following is a result of running the code:
$ python3 prog.py --help $ python3 prog.py --help
usage: prog.py [-h] usage: prog.py [-h]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
$ python3 prog.py --verbose $ python3 prog.py --verbose
usage: prog.py [-h] usage: prog.py [-h]
@ -130,7 +130,7 @@ And running the code:
positional arguments: positional arguments:
echo echo
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
$ python3 prog.py foo $ python3 prog.py foo
foo foo
@ -172,7 +172,7 @@ And we get:
positional arguments: positional arguments:
echo echo the string you use here echo echo the string you use here
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
Now, how about doing something even more useful:: Now, how about doing something even more useful::
@ -241,7 +241,7 @@ And the output:
$ python3 prog.py --help $ python3 prog.py --help
usage: prog.py [-h] [--verbosity VERBOSITY] usage: prog.py [-h] [--verbosity VERBOSITY]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--verbosity VERBOSITY --verbosity VERBOSITY
increase output verbosity increase output verbosity
@ -289,7 +289,7 @@ And the output:
$ python3 prog.py --help $ python3 prog.py --help
usage: prog.py [-h] [--verbose] usage: prog.py [-h] [--verbose]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--verbose increase output verbosity --verbose increase output verbosity
@ -332,7 +332,7 @@ And here goes:
$ python3 prog.py --help $ python3 prog.py --help
usage: prog.py [-h] [-v] usage: prog.py [-h] [-v]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --verbose increase output verbosity -v, --verbose increase output verbosity
@ -440,7 +440,7 @@ And the output:
positional arguments: positional arguments:
square display a square of a given number square display a square of a given number
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v {0,1,2}, --verbosity {0,1,2} -v {0,1,2}, --verbosity {0,1,2}
increase output verbosity increase output verbosity
@ -468,7 +468,8 @@ verbosity argument (check the output of ``python --help``)::
print(answer) print(answer)
We have introduced another action, "count", We have introduced another action, "count",
to count the number of occurrences of a specific optional arguments: to count the number of occurrences of specific options.
.. code-block:: shell-session .. code-block:: shell-session
@ -489,7 +490,7 @@ to count the number of occurrences of a specific optional arguments:
positional arguments: positional arguments:
square display a square of a given number square display a square of a given number
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --verbosity increase output verbosity -v, --verbosity increase output verbosity
$ python3 prog.py 4 -vvv $ python3 prog.py 4 -vvv
@ -626,7 +627,7 @@ Output:
x the base x the base
y the exponent y the exponent
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --verbosity -v, --verbosity
$ python3 prog.py 4 2 -v $ python3 prog.py 4 2 -v
@ -750,7 +751,7 @@ but not both at the same time:
x the base x the base
y the exponent y the exponent
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --verbose -v, --verbose
-q, --quiet -q, --quiet

View File

@ -57,7 +57,7 @@ be run at the command line and provides useful help messages:
positional arguments: positional arguments:
N an integer for the accumulator N an integer for the accumulator
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--sum sum the integers (default: find the max) --sum sum the integers (default: find the max)
@ -217,14 +217,14 @@ The help for this program will display ``myprogram.py`` as the program name
$ python myprogram.py --help $ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO] usage: myprogram.py [-h] [--foo FOO]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
$ cd .. $ cd ..
$ python subdir/myprogram.py --help $ python subdir/myprogram.py --help
usage: myprogram.py [-h] [--foo FOO] usage: myprogram.py [-h] [--foo FOO]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
@ -235,7 +235,7 @@ To change this default behavior, another value can be supplied using the
>>> parser.print_help() >>> parser.print_help()
usage: myprogram [-h] usage: myprogram [-h]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
Note that the program name, whether determined from ``sys.argv[0]`` or from the Note that the program name, whether determined from ``sys.argv[0]`` or from the
@ -249,7 +249,7 @@ specifier.
>>> parser.print_help() >>> parser.print_help()
usage: myprogram [-h] [--foo FOO] usage: myprogram [-h] [--foo FOO]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo of the myprogram program --foo FOO foo of the myprogram program
@ -269,7 +269,7 @@ arguments it contains::
positional arguments: positional arguments:
bar bar help bar bar help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo [FOO] foo help --foo [FOO] foo help
@ -284,7 +284,7 @@ The default message can be overridden with the ``usage=`` keyword argument::
positional arguments: positional arguments:
bar bar help bar bar help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo [FOO] foo help --foo [FOO] foo help
@ -307,7 +307,7 @@ various arguments::
A foo that bars A foo that bars
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
By default, the description will be line-wrapped so that it fits within the By default, the description will be line-wrapped so that it fits within the
@ -329,7 +329,7 @@ argument to :class:`ArgumentParser`::
A foo that bars A foo that bars
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
And that's how you'd foo a bar And that's how you'd foo a bar
@ -403,7 +403,7 @@ epilog_ texts in command-line help messages::
this description was indented weird but that is okay this description was indented weird but that is okay
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
likewise for this epilog whose whitespace will be cleaned up and whose words likewise for this epilog whose whitespace will be cleaned up and whose words
@ -432,7 +432,7 @@ should not be line-wrapped::
exactly the way exactly the way
I want it I want it
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
:class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text, :class:`RawTextHelpFormatter` maintains whitespace for all sorts of help text,
@ -454,7 +454,7 @@ default values to each of the argument help messages::
positional arguments: positional arguments:
bar BAR! (default: [1, 2, 3]) bar BAR! (default: [1, 2, 3])
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO FOO! (default: 42) --foo FOO FOO! (default: 42)
@ -473,7 +473,7 @@ as the regular formatter does)::
positional arguments: positional arguments:
float float
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo int --foo int
@ -592,7 +592,7 @@ older arguments with the same option string. To get this behavior, the value
>>> parser.print_help() >>> parser.print_help()
usage: PROG [-h] [-f FOO] [--foo FOO] usage: PROG [-h] [-f FOO] [--foo FOO]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-f FOO old foo help -f FOO old foo help
--foo FOO new foo help --foo FOO new foo help
@ -623,7 +623,7 @@ help will be printed:
$ python myprogram.py --help $ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO] usage: myprogram.py [-h] [--foo FOO]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
@ -636,7 +636,7 @@ This can be achieved by passing ``False`` as the ``add_help=`` argument to
>>> parser.print_help() >>> parser.print_help()
usage: PROG [--foo FOO] usage: PROG [--foo FOO]
optional arguments: options:
--foo FOO foo help --foo FOO foo help
The help option is typically ``-h/--help``. The exception to this is The help option is typically ``-h/--help``. The exception to this is
@ -649,7 +649,7 @@ the help options::
>>> parser.print_help() >>> parser.print_help()
usage: PROG [+h] usage: PROG [+h]
optional arguments: options:
+h, ++help show this help message and exit +h, ++help show this help message and exit
@ -1203,7 +1203,7 @@ argument::
positional arguments: positional arguments:
bar one of the bars to be frobbled bar one of the bars to be frobbled
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo the bars before frobbling --foo foo the bars before frobbling
@ -1221,7 +1221,7 @@ specifiers include the program name, ``%(prog)s`` and most keyword arguments to
positional arguments: positional arguments:
bar the bar to frobble (default: 42) bar the bar to frobble (default: 42)
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
As the help string supports %-formatting, if you want a literal ``%`` to appear As the help string supports %-formatting, if you want a literal ``%`` to appear
@ -1235,7 +1235,7 @@ setting the ``help`` value to ``argparse.SUPPRESS``::
>>> parser.print_help() >>> parser.print_help()
usage: frobble [-h] usage: frobble [-h]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
@ -1262,7 +1262,7 @@ will be referred to as ``FOO``. An example::
positional arguments: positional arguments:
bar bar
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO --foo FOO
@ -1279,7 +1279,7 @@ An alternative name can be specified with ``metavar``::
positional arguments: positional arguments:
XXX XXX
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo YYY --foo YYY
@ -1297,7 +1297,7 @@ arguments::
>>> parser.print_help() >>> parser.print_help()
usage: PROG [-h] [-x X X] [--foo bar baz] usage: PROG [-h] [-x X X] [--foo bar baz]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X X -x X X
--foo bar baz --foo bar baz
@ -1701,7 +1701,7 @@ Sub-commands
a a help a a help
b b help b b help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo help --foo foo help
@ -1711,13 +1711,13 @@ Sub-commands
positional arguments: positional arguments:
bar bar help bar bar help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
>>> parser.parse_args(['b', '--help']) >>> parser.parse_args(['b', '--help'])
usage: PROG b [-h] [--baz {X,Y,Z}] usage: PROG b [-h] [--baz {X,Y,Z}]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--baz {X,Y,Z} baz help --baz {X,Y,Z} baz help
@ -1734,7 +1734,7 @@ Sub-commands
>>> parser.parse_args(['-h']) >>> parser.parse_args(['-h'])
usage: [-h] {foo,bar} ... usage: [-h] {foo,bar} ...
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
subcommands: subcommands:

View File

@ -1719,7 +1719,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
add_group = self.add_argument_group add_group = self.add_argument_group
self._positionals = add_group(_('positional arguments')) self._positionals = add_group(_('positional arguments'))
self._optionals = add_group(_('optional arguments')) self._optionals = add_group(_('options'))
self._subparsers = None self._subparsers = None
# register types # register types

View File

@ -2078,7 +2078,7 @@ class TestAddSubparsers(TestCase):
bar bar help bar bar help
{1,2,3} command help {1,2,3} command help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo help --foo foo help
''')) '''))
@ -2097,7 +2097,7 @@ class TestAddSubparsers(TestCase):
bar bar help bar bar help
{1,2,3} command help {1,2,3} command help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
++foo foo help ++foo foo help
''')) '''))
@ -2114,7 +2114,7 @@ class TestAddSubparsers(TestCase):
main description main description
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--non-breaking help message containing non-breaking spaces shall not --non-breaking help message containing non-breaking spaces shall not
wrap\N{NO-BREAK SPACE}at non-breaking spaces wrap\N{NO-BREAK SPACE}at non-breaking spaces
@ -2133,7 +2133,7 @@ class TestAddSubparsers(TestCase):
bar bar help bar bar help
{1,2,3} command help {1,2,3} command help
optional arguments: options:
+h, ++help show this help message and exit +h, ++help show this help message and exit
++foo foo help ++foo foo help
''')) '''))
@ -2154,7 +2154,7 @@ class TestAddSubparsers(TestCase):
2 2 help 2 2 help
3 3 help 3 3 help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo help --foo foo help
''')) '''))
@ -2179,7 +2179,7 @@ class TestAddSubparsers(TestCase):
positional arguments: positional arguments:
bar bar help bar bar help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo help --foo foo help
@ -2203,7 +2203,7 @@ class TestAddSubparsers(TestCase):
positional arguments: positional arguments:
{a,b,c} x help {a,b,c} x help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w W w help -w W w help
''')) '''))
@ -2217,7 +2217,7 @@ class TestAddSubparsers(TestCase):
positional arguments: positional arguments:
z z help z z help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-y {1,2,3} y help -y {1,2,3} y help
''')) '''))
@ -2249,7 +2249,7 @@ class TestAddSubparsers(TestCase):
positional arguments: positional arguments:
bar bar help bar bar help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo foo help --foo foo help
@ -2437,7 +2437,7 @@ class TestParentParsers(TestCase):
a a
z z
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-b B -b B
--w W --w W
@ -2467,7 +2467,7 @@ class TestParentParsers(TestCase):
self.assertEqual(parser_help, textwrap.dedent('''\ self.assertEqual(parser_help, textwrap.dedent('''\
usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z] usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-y Y -y Y
-z Z -z Z
@ -2512,7 +2512,7 @@ class TestMutuallyExclusiveGroupErrors(TestCase):
expected = '''\ expected = '''\
usage: PROG [-h] [--foo | --bar] [--soup | --nuts] usage: PROG [-h] [--foo | --bar] [--soup | --nuts]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo --foo
--bar --bar
@ -2597,7 +2597,7 @@ class TestMutuallyExclusiveSimple(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--bar BAR bar help --bar BAR bar help
--baz [BAZ] baz help --baz [BAZ] baz help
@ -2638,7 +2638,7 @@ class TestMutuallyExclusiveLong(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--abcde ABCDE abcde help --abcde ABCDE abcde help
--fghij FGHIJ fghij help --fghij FGHIJ fghij help
@ -2674,7 +2674,7 @@ class TestMutuallyExclusiveFirstSuppressed(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-y y help -y y help
''' '''
@ -2711,7 +2711,7 @@ class TestMutuallyExclusiveManySuppressed(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
''' '''
@ -2754,7 +2754,7 @@ class TestMutuallyExclusiveOptionalAndPositional(MEMixin, TestCase):
positional arguments: positional arguments:
badger BADGER badger BADGER
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO --foo FOO
--spam SPAM SPAM --spam SPAM SPAM
@ -2793,7 +2793,7 @@ class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x x help -x x help
-a a help -a a help
@ -2832,7 +2832,7 @@ class TestMutuallyExclusiveInGroup(MEMixin, TestCase):
''' '''
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
Titled group: Titled group:
@ -2877,7 +2877,7 @@ class TestMutuallyExclusiveOptionalsAndPositionalsMixed(MEMixin, TestCase):
x x help x x help
a a help a a help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-y y help -y y help
-b b help -b b help
@ -2908,7 +2908,7 @@ class TestMutuallyExclusiveNested(MEMixin, TestCase):
help = '''\ help = '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-a A -a A
-b B -b B
@ -3226,7 +3226,7 @@ class TestHelpBiggerOptionals(HelpTestCase):
foo FOO HELP foo FOO HELP
bar BAR HELP bar BAR HELP
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version show program's version number and exit -v, --version show program's version number and exit
-x X HELP -x X HELP
@ -3271,7 +3271,7 @@ class TestShortColumns(HelpTestCase):
bar bar
BAR HELP BAR HELP
optional arguments: options:
-h, --help -h, --help
show this show this
help help
@ -3321,7 +3321,7 @@ class TestHelpBiggerOptionalGroups(HelpTestCase):
foo FOO HELP foo FOO HELP
bar BAR HELP bar BAR HELP
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version show program's version number and exit -v, --version show program's version number and exit
-x X HELP -x X HELP
@ -3362,7 +3362,7 @@ class TestHelpBiggerPositionals(HelpTestCase):
ekiekiekifekang EKI HELP ekiekiekifekang EKI HELP
bar BAR HELP bar BAR HELP
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X HELP -x X HELP
--y Y Y HELP --y Y Y HELP
@ -3409,7 +3409,7 @@ multiple
positional arguments: positional arguments:
yyy normal y help yyy normal y help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x XX oddly formatted -x help -x XX oddly formatted -x help
@ -3449,7 +3449,7 @@ DD DD DD
YHYH YHYH YHYH YHYH
YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x XX XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH \ -x XX XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH \
HXXHH HXXHH HXXHH HXXHH
@ -3492,7 +3492,7 @@ DD DD DD
YHYH YHYH YHYH YHYH
YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version show program's version number and exit -v, --version show program's version number and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX -x XXXXXXXXXXXXXXXXXXXXXXXXX
@ -3554,7 +3554,7 @@ class TestHelpUsage(HelpTestCase):
b b b b
c c c c
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w W [W ...] w -w W [W ...] w
-x [X ...] x -x [X ...] x
@ -3623,7 +3623,7 @@ class TestHelpUsageLongProg(HelpTestCase):
a a
b b
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w W -w W
-x X -x X
@ -3657,7 +3657,7 @@ class TestHelpUsageLongProgOptionsWrap(HelpTestCase):
a a
b b
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w WWWWWWWWWWWWWWWWWWWWWWWWW -w WWWWWWWWWWWWWWWWWWWWWWWWW
-x XXXXXXXXXXXXXXXXXXXXXXXXX -x XXXXXXXXXXXXXXXXXXXXXXXXX
@ -3720,7 +3720,7 @@ class TestHelpUsageOptionalsWrap(HelpTestCase):
b b
c c
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w WWWWWWWWWWWWWWWWWWWWWWWWW -w WWWWWWWWWWWWWWWWWWWWWWWWW
-x XXXXXXXXXXXXXXXXXXXXXXXXX -x XXXXXXXXXXXXXXXXXXXXXXXXX
@ -3755,7 +3755,7 @@ class TestHelpUsagePositionalsWrap(HelpTestCase):
bbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc ccccccccccccccccccccccccc
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X -x X
-y Y -y Y
@ -3791,7 +3791,7 @@ class TestHelpUsageOptionalsPositionalsWrap(HelpTestCase):
bbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc ccccccccccccccccccccccccc
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX -x XXXXXXXXXXXXXXXXXXXXXXXXX
-y YYYYYYYYYYYYYYYYYYYYYYYYY -y YYYYYYYYYYYYYYYYYYYYYYYYY
@ -3817,7 +3817,7 @@ class TestHelpUsageOptionalsOnlyWrap(HelpTestCase):
''' '''
help = usage + '''\ help = usage + '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x XXXXXXXXXXXXXXXXXXXXXXXXX -x XXXXXXXXXXXXXXXXXXXXXXXXX
-y YYYYYYYYYYYYYYYYYYYYYYYYY -y YYYYYYYYYYYYYYYYYYYYYYYYY
@ -3882,7 +3882,7 @@ class TestHelpVariableExpansion(HelpTestCase):
spam spam PROG None spam spam PROG None
badger badger PROG 0.5 badger badger PROG 0.5
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X x PROG None int % -x X x PROG None int %
-y y PROG 42 XXX -y y PROG 42 XXX
@ -3907,7 +3907,7 @@ class TestHelpVariableExpansionUsageSupplied(HelpTestCase):
''') ''')
help = usage + '''\ help = usage + '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
''' '''
version = '' version = ''
@ -3939,7 +3939,7 @@ class TestHelpSuppressUsage(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
''' '''
@ -3986,7 +3986,7 @@ class TestHelpSuppressOptionalGroup(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
''' '''
@ -4007,7 +4007,7 @@ class TestHelpSuppressPositional(HelpTestCase):
''' '''
help = usage + '''\ help = usage + '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
''' '''
@ -4027,7 +4027,7 @@ class TestHelpRequiredOptional(HelpTestCase):
''' '''
help = usage + '''\ help = usage + '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
''' '''
@ -4048,7 +4048,7 @@ class TestHelpAlternatePrefixChars(HelpTestCase):
''' '''
help = usage + '''\ help = usage + '''\
optional arguments: options:
^^foo foo help ^^foo foo help
;b BAR, ;;bar BAR bar help ;b BAR, ;;bar BAR bar help
''' '''
@ -4072,7 +4072,7 @@ class TestHelpNoHelpOptional(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
--foo FOO foo help --foo FOO foo help
''' '''
version = '' version = ''
@ -4095,7 +4095,7 @@ class TestHelpNone(HelpTestCase):
positional arguments: positional arguments:
spam spam
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO --foo FOO
''' '''
@ -4119,7 +4119,7 @@ class TestHelpTupleMetavar(HelpTestCase):
''' '''
help = usage + '''\ help = usage + '''\
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w W1 [W2 ...] w -w W1 [W2 ...] w
-x [X1 [X2 ...]] x -x [X1 [X2 ...]] x
@ -4163,7 +4163,7 @@ class TestHelpRawText(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help should also --foo FOO foo help should also
appear as given here appear as given here
@ -4212,7 +4212,7 @@ class TestHelpRawDescription(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help should not retain this odd formatting --foo FOO foo help should not retain this odd formatting
@ -4254,7 +4254,7 @@ class TestHelpArgumentDefaults(HelpTestCase):
spam spam help spam spam help
badger badger help (default: wooden) badger badger help (default: wooden)
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help - oh and by the way, None --foo FOO foo help - oh and by the way, None
--bar bar help (default: False) --bar bar help (default: False)
@ -4279,7 +4279,7 @@ class TestHelpVersionAction(HelpTestCase):
description description
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-V, --version show program's version number and exit -V, --version show program's version number and exit
''' '''
@ -4305,7 +4305,7 @@ class TestHelpVersionActionSuppress(HelpTestCase):
positional arguments: positional arguments:
spam spam help spam spam help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--foo FOO foo help --foo FOO foo help
''' '''
@ -4331,7 +4331,7 @@ class TestHelpSubparsersOrdering(HelpTestCase):
positional arguments: positional arguments:
{a,b,c,d,e} {a,b,c,d,e}
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version show program's version number and exit -v, --version show program's version number and exit
''' '''
@ -4372,7 +4372,7 @@ class TestHelpSubparsersWithHelpOrdering(HelpTestCase):
d d subcommand help d d subcommand help
e e subcommand help e e subcommand help
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version show program's version number and exit -v, --version show program's version number and exit
''' '''
@ -4404,7 +4404,7 @@ class TestHelpMetavarTypeFormatter(HelpTestCase):
positional arguments: positional arguments:
int int
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-b custom_type -b custom_type
-c SOME FLOAT -c SOME FLOAT
@ -4596,7 +4596,7 @@ class TestConflictHandling(TestCase):
self.assertEqual(parser.format_help(), textwrap.dedent('''\ self.assertEqual(parser.format_help(), textwrap.dedent('''\
usage: PROG [-h] [-x X] usage: PROG [-h] [-x X]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X NEW X -x X NEW X
''')) '''))
@ -4606,7 +4606,7 @@ class TestConflictHandling(TestCase):
self.assertEqual(parser.format_help(), textwrap.dedent('''\ self.assertEqual(parser.format_help(), textwrap.dedent('''\
usage: PROG [-h] [-x X] [--spam NEW_SPAM] usage: PROG [-h] [-x X] [--spam NEW_SPAM]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-x X NEW X -x X NEW X
--spam NEW_SPAM --spam NEW_SPAM
@ -5337,7 +5337,7 @@ class TestWrappingMetavar(TestCase):
usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name
[-h] [--proxy <http[s]://example:1234>] [-h] [--proxy <http[s]://example:1234>]
optional arguments: options:
-h, --help show this help message and exit -h, --help show this help message and exit
--proxy <http[s]://example:1234> --proxy <http[s]://example:1234>
''')) '''))

View File

@ -0,0 +1,2 @@
Argparse help no longer uses the confusing phrase, "optional arguments".
It uses "options" instead.