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 falu2010, paul.j3
Date 2017-02-27.23:48:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488239311.17.0.201013695315.issue29626@psf.upfronthosting.co.za>
In-reply-to
Content
Sorry, I missed that.  For some reason I looking something bigger.

That's coming from the `metavar=""'.

If I specify `metavar="xxx" that help line will have

    -p xxx, --projectid xxx

Replace the 'xxx` with '', and you still have space between '-p' and ','.

Now that I see it, it looks familiar.  I noted it in passing in StackOverflow answer, http://stackoverflow.com/a/40497623/901925

I can't find a related bug/issue.  

It's a natural consequence of the formatting in HelpFormatter._format_action_invocation

            # if the Optional takes a value, format is:
            #    -s ARGS, --long ARGS
            parts.append('%s %s' % (option_string, args_string))

There's no special handling for the case where ARGS is blank.

That formatter method could be customized as suggested in 

http://stackoverflow.com/a/23941599/901925

Often people want a more compact invocation like:

  -s, --long ARG    help

Usage gets that space between option_string and args_string, but it gets striped out later.

So the fix (not tested) would something like:

      def _format_action_invocation(self, action):
           ....
           for option_string in action.option_strings:
               if len(args_string)>0:
                    parts.append('%s %s' % (option_string, args_string))
               else:
                    parts.append('%s' % option_string)
           ....
History
Date User Action Args
2017-02-27 23:48:31paul.j3setrecipients: + paul.j3, falu2010
2017-02-27 23:48:31paul.j3setmessageid: <1488239311.17.0.201013695315.issue29626@psf.upfronthosting.co.za>
2017-02-27 23:48:31paul.j3linkissue29626 messages
2017-02-27 23:48:30paul.j3create