classification
Title: Argparse required arguments incorrectly displayed as optional arguments
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: argparse required arguments displayed under "optional arguments"
View: 9694
Assigned To: Nosy List: bethard, eric.araujo, ezio.melotti, rhettinger
Priority: normal Keywords:

Created on 2012-07-12 19:43 by rhettinger, last changed 2012-07-22 23:39 by bethard. This issue is now closed.

Messages (1)
msg165331 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-07-12 19:43
In this script, '-x' is required argument:
------------------------------------------
import argparse
p = argparse.ArgumentParser()
p.add_argument('-x', required=True)
p.print_help()

However, the automatically generated help shows it as optional:
---------------------------------------------------------------
usage: ap_demo.py [-h] -x X

optional arguments:
  -h, --help  show this help message and exit
  -x X
History
Date User Action Args
2012-07-22 23:39:04bethardsetstatus: open -> closed
superseder: argparse required arguments displayed under "optional arguments"
resolution: duplicate
2012-07-14 12:55:12eric.araujosetnosy: + eric.araujo
2012-07-13 03:53:39ezio.melottisetnosy: + bethard, ezio.melotti

stage: needs patch
2012-07-12 19:43:34rhettingercreate