-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Without color, argparse strips the outer [] in a group. But it is not stripped with color.
The following example:
import argparse
parser = argparse.ArgumentParser(color=False, prog="PROG")
group = parser.add_mutually_exclusive_group()
group.add_argument('--foo', action='store_true', help='FOO')
group.add_argument('--spam', help='SPAM')
group.add_argument('badger', nargs='*', help='BADGER')
print(parser.format_usage())
parser = argparse.ArgumentParser(color=True, prog="PROG")
group = parser.add_mutually_exclusive_group()
group.add_argument('--foo', action='store_true', help='FOO')
group.add_argument('--spam', help='SPAM')
group.add_argument('badger', nargs='*', help='BADGER')
print(parser.format_usage())outputs:
usage: PROG [-h] [--foo | --spam SPAM | badger ...]
usage: PROG [-h] [--foo | --spam SPAM | [badger ...]]
(the latter line in color).
Linked PRs
savannahostrowski
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Doc issues