diff options
author | steven.bethard <devnull@localhost> | 2010-02-28 06:49:22 +0000 |
---|---|---|
committer | steven.bethard <devnull@localhost> | 2010-02-28 06:49:22 +0000 |
commit | 22948d838fa22c160682419b4be9be7f421c5e39 (patch) | |
tree | f268ce5ee874bd0b2ba2c72adc2a9a9cfd82ef41 /argparse.py | |
parent | 368317de60c7dcf7c080593270c3fb5a5af1a5ba (diff) | |
download | argparse-22948d838fa22c160682419b4be9be7f421c5e39.tar.gz |
Deprecate ArgumentParser(..., version=XXX, ...) as well as format_version() and print_version(). These should be replaced with .add_argument(..., action='version', ...).
Diffstat (limited to 'argparse.py')
-rw-r--r-- | argparse.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/argparse.py b/argparse.py index 83844d7..fd21104 100644 --- a/argparse.py +++ b/argparse.py @@ -1543,7 +1543,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): - usage -- A usage message (default: auto-generated from arguments) - description -- A description of what the program does - epilog -- Text following the argument descriptions - - version -- Add a -v/--version option with the given version string - parents -- Parsers whose arguments should be copied into this one - formatter_class -- HelpFormatter class for printing help messages - prefix_chars -- Characters that prefix optional arguments @@ -1568,6 +1567,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): conflict_handler='error', add_help=True): + if version is not None: + import warnings + warnings.warn( + """The "version" argument to ArgumentParser is deprecated. """ + """Please use """ + """"add_argument(..., action='version', version="N", ...)" """ + """instead""", DeprecationWarning) + superinit = super(ArgumentParser, self).__init__ superinit(description=description, prefix_chars=prefix_chars, @@ -2286,6 +2293,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): return formatter.format_help() def format_version(self): + import warnings + warnings.warn( + 'The format_version method is deprecated -- the "version" ' + 'argument to ArgumentParser is no longer supported.', + DeprecationWarning) formatter = self._get_formatter() formatter.add_text(self.version) return formatter.format_help() @@ -2307,6 +2319,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): self._print_message(self.format_help(), file) def print_version(self, file=None): + import warnings + warnings.warn( + 'The print_version method is deprecated -- the "version" ' + 'argument to ArgumentParser is no longer supported.', + DeprecationWarning) self._print_message(self.format_version(), file) def _print_message(self, message, file=None): |