summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@gmail.com>2019-11-11 20:47:48 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2019-11-11 20:47:48 (GMT)
commita0ed99bca8475cbc82e9202aa354faba2a4620f4 (patch)
tree711f4057ace58c12f19608a0a428c64724a9b882 /Lib/argparse.py
parent84ac4376587e35d16b4d0977c4f330d9d04b690a (diff)
downloadcpython-a0ed99bca8475cbc82e9202aa354faba2a4620f4.zip
cpython-a0ed99bca8475cbc82e9202aa354faba2a4620f4.tar.gz
cpython-a0ed99bca8475cbc82e9202aa354faba2a4620f4.tar.bz2
bpo-38438: Simplify argparse "star nargs" usage. (GH-17106)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 13af7ac..94e1b8a 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -591,7 +591,11 @@ class HelpFormatter(object):
elif action.nargs == OPTIONAL:
result = '[%s]' % get_metavar(1)
elif action.nargs == ZERO_OR_MORE:
- result = '[%s [%s ...]]' % get_metavar(2)
+ metavar = get_metavar(1)
+ if len(metavar) == 2:
+ result = '[%s [%s ...]]' % metavar
+ else:
+ result = '[%s ...]' % metavar
elif action.nargs == ONE_OR_MORE:
result = '%s [%s ...]' % get_metavar(2)
elif action.nargs == REMAINDER: