def add_dummy_redirect_argument(self, expected_name):
# type: (argparse.ArgumentParser, str) -> None
"""Adds a dummy redirect argument to the provided parser to catch typos when calling
the specified valid long-form name.
:param parser: Parser to which to add argument
:type parser: argparse.ArgumentParser
:param str expected_name: Valid long-form name for which to add dummy redirect
"""
self.add_argument(
expected_name[1:],
dest='dummy_redirect',
action='store_const',
const=expected_name[1:],
help=argparse.SUPPRESS
)
# ArgumentParser subclass confuses mypy
self.__dummy_arguments.append(expected_name[1:]) # type: ignore
评论列表
文章目录