Issue 25600: argparse, argument_default=argparse.SUPPRESS seems to have no effect (original) (raw)

The parameter argument_default=argparse.SUPPRESS seems to have no effect. Example:

=====================================================================

help_dirs='ahoy

parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description='Makes the calendar for the "year"', epilog=textwrap.dedent(help_dirs)) parser.add_argument("user", help='the user directory with the required structure in ./') parser.add_argument("year", type=int, help='the year for this calendar and also the directory for the output') parser.add_argument("-acc","--acc", default='no',nargs='?',choices=['yes','no'],const='yes', help='accomodate ratio according to the cover photo, default=no') parser.add_argument("--color",default='gold', choices=['gold'], help='default color: gold') args = parser.parse_args(['mc', '2015']) print(args) del parser del args

parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS, formatter_class=argparse.RawDescriptionHelpFormatter, description='Makes the calendar for the "year"', epilog=textwrap.dedent(help_dirs)) parser.add_argument("user", help='the user directory with the required structure in ./') parser.add_argument("year", type=int, help='the year for this calendar and also the directory for the output') parser.add_argument("-acc","--acc", default='no',nargs='?',choices=['yes','no'],const='yes', help='accomodate ratio according to the cover photo, default=no') parser.add_argument("--color",default='gold', choices=['gold'], help='default color: gold') args = parser.parse_args(['mc', '2015'])

===================================

The results in both cases are the same: Namespace(acc='no', color='gold', user='mc', year=2015)

I hoped the defaults will be suppressed.