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 paul.j3
Recipients Albert White, Martin.d'Anjou, Oliver.Smith, benschmaus, bethard, docs@python, eric.araujo, eric.smith, martin.panter, mburger, paul.j3, r.david.murray, rhartkopf, rhettinger, shaharg, terry.reedy, tonygaetani, tshepang
Date 2016-03-23.19:21:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458760870.93.0.510524470784.issue9694@psf.upfronthosting.co.za>
In-reply-to
Content
This ArgumentDefaultHelpFormatter issue should probably be raised in its own issue.  It applies to 'required' optionals, but any patch would be independent of the issues discussed here.

This class defines a method that adds the '%(default)' string to the help in certain situations.  It already skips required positionals.  So adding a test for 'action.required' should be easy.

    def _get_help_string(self, action):
        help = action.help
        if '%(default)' not in action.help:
            if action.default is not SUPPRESS:
                defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
                if action.option_strings or action.nargs in defaulting_nargs:
                    help += ' (default: %(default)s)'
        return help

There are 2 easy user fixes.

- a custom HelpFormatter class that implements this fix.  

- 'default=argparse.SUPPRESS' for arguments where you do not want to see the default.  This SUPPRESS is checked else where in the code, but for a required argument I don't think that matters (but it needs testing).
History
Date User Action Args
2016-03-23 19:21:10paul.j3setrecipients: + paul.j3, rhettinger, terry.reedy, bethard, eric.smith, eric.araujo, r.david.murray, docs@python, benschmaus, tshepang, martin.panter, mburger, Martin.d'Anjou, Oliver.Smith, rhartkopf, Albert White, tonygaetani, shaharg
2016-03-23 19:21:10paul.j3setmessageid: <1458760870.93.0.510524470784.issue9694@psf.upfronthosting.co.za>
2016-03-23 19:21:10paul.j3linkissue9694 messages
2016-03-23 19:21:10paul.j3create