bpo-29553: Fix ArgumentParser.format_usage() for mutually exclusive groups (GH-14976)

Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
This commit is contained in:
Flavian Hautbois 2019-08-25 21:06:45 +02:00 committed by Berker Peksag
parent 5dbe0f59b7
commit da27d9b9dc
3 changed files with 50 additions and 2 deletions

View file

@ -404,13 +404,19 @@ class HelpFormatter(object):
inserts[start] += ' ['
else:
inserts[start] = '['
inserts[end] = ']'
if end in inserts:
inserts[end] += ']'
else:
inserts[end] = ']'
else:
if start in inserts:
inserts[start] += ' ('
else:
inserts[start] = '('
inserts[end] = ')'
if end in inserts:
inserts[end] += ')'
else:
inserts[end] = ')'
for i in range(start + 1, end):
inserts[i] = '|'