This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author acooke
Recipients acooke
Date 2021-11-02.13:39:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635860360.92.0.910770346728.issue45690@roundup.psfhosted.org>
In-reply-to
Content
The code below, when invoked with -h, prints:

(.env) [andrew@localhost py]$ python -m tests_sa.argparse_bug -h
usage: argparse_bug.py [-h] (-a A | [-b B | -c C)]

options:
  -h, --help  show this help message and exit
  -a A
  -b B
  -c C

where the final two characters in the usage line are swapped.  It should be

usage: argparse_bug.py [-h] (-a A | [-b B | -c C])

or maybe even

usage: argparse_bug.py [-h] (-a A | (-b B | -c C))



from argparse import ArgumentParser

def main():
    parser = ArgumentParser()
    outer = parser.add_mutually_exclusive_group(required=True)
    outer.add_argument('-a')
    inner = outer.add_mutually_exclusive_group()
    inner.add_argument('-b')
    inner.add_argument('-c')
    parser.parse_args()


if __name__ == '__main__':
    main()
History
Date User Action Args
2021-11-02 13:39:20acookesetrecipients: + acooke
2021-11-02 13:39:20acookesetmessageid: <1635860360.92.0.910770346728.issue45690@roundup.psfhosted.org>
2021-11-02 13:39:20acookelinkissue45690 messages
2021-11-02 13:39:20acookecreate