def add_argument(self, *args, **kwargs):
# The type profile for this it really complex and we don't do anything substantive
# to it, so I would rather not duplicate the typeshed's effort keeping it up to date.
# https://github.com/python/typeshed/blob/master/stdlib/2and3/argparse.pyi#L53-L65
"""Adds the requested argument to the parser, also adding a dummy redirect argument
if a long-form argument (starts with two starting prefix characters) is found.
See: https://docs.python.org/dev/library/argparse.html#the-add-argument-method
"""
for long_arg in [arg for arg in args if arg.startswith(self.prefix_chars * 2)]:
self.add_dummy_redirect_argument(long_arg)
return super(CommentIgnoringArgumentParser, self).add_argument(*args, **kwargs)
评论列表
文章目录