#1493 cli: formally deprecate --memory option
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.
Unknown source cli-dont-dump-memory  into  master

file modified
+12 -1
@@ -10,6 +10,7 @@

  import subprocess

  import sys

  import time

+ import warnings

  from collections import defaultdict

  

  import six
@@ -81,6 +82,15 @@

          )

  

  

+ class ActionDeprecated(argparse.Action):

This could easily be just a function but I don't mind having a class with __call__ either.

+     """ automate deprecation warnings for options """

+     def __call__(self, parser, namespace, values, option_string=None):

+         options = ", ".join(self.option_strings)

+         warnings.warn("Use of DEPRECATED option: {0}".format(options))

+         # keep the normal "store" behavior

+         setattr(namespace, self.dest, values)

+ 

+ 

  class Commands(object):

      def __init__(self, config_path):

          self.config_path = config_path or '~/.config/copr'
@@ -1019,7 +1029,8 @@

                                       help="The copr repo to build the package in. Can be just name of project or even in format username/project or @groupname/project. "

                                       "It can also be in the form project:<tag>, which will put the build into a side repository with the user-chosen tag in its name.")

      parser_build_parent.add_argument("--memory", dest="memory",

-                                      help="")

+                                      help=argparse.SUPPRESS,

+                                      action=ActionDeprecated)

      parser_build_parent.add_argument("--timeout", dest="timeout",

                                       help="")

      parser_build_parent.add_argument("--nowait", action="store_true", default=False,

That option had never a real effect, and we now don't even dropped the
remaining parts of this idea in Frontend (PR#1480).

So throw a warning if anyone by accident uses this option. It also
doesn't make sense to complicate the --help output by that option, so
suppress it.

I forgot the option also exists in cli.
+1

This could easily be just a function but I don't mind having a class with __call__ either.

rebased onto 63e524a

3 years ago

Pull-Request has been merged by praiskup

3 years ago