# Buggy code
def add_deprecated_argument(add_argument, argument_name, nargs):
    """Adds a deprecated argument with the name argument_name.

    Deprecated arguments are not shown in the help. If they are used on
    the command line, a warning is shown stating that the argument is
    deprecated and no other action is taken.

    :param callable add_argument: Function that adds arguments to an
        argument parser/group.
    :param str argument_name: Name of deprecated argument.
    :param nargs: Value for nargs when adding the argument to argparse.

    """

    class ShowWarning(argparse.Action):
        """Action to log a warning when an argument is used."""

        def __call__(self, unused1, unused2, unused3, option_string=None):
            sys.stderr.write("Use of {0} is deprecated.\n".format(option_string))

    configargparse.ACTION_TYPES_THAT_DONT_NEED_A_VALUE.add(ShowWarning)
    add_argument(argument_name, action=ShowWarning, help=argparse.SUPPRESS, nargs=nargs)


# Traceback (AttributeError)
# cat /tmp/tmpsCKLky
2017-05-12 16:49:25,831:DEBUG:certbot.main:certbot version: 0.14.0
2017-05-12 16:49:25,832:DEBUG:certbot.main:Arguments: []
2017-05-12 16:49:25,832:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2017-05-12 16:49:25,835:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
File "/usr/local/share/letsencrypt/env/bin/letsencrypt", line 11, in <module>
sys.exit(main())
File "/usr/local/share/letsencrypt/env/local/lib/python2.7/site-packages/certbot/main.py", line 729, in main
args = cli.prepare_and_parse_args(plugins, cli_args)
File "/usr/local/share/letsencrypt/env/local/lib/python2.7/site-packages/certbot/cli.py", line 1089, in prepare_and_parse_args
helpful.add_deprecated_argument("--agree-dev-preview", 0)
File "/usr/local/share/letsencrypt/env/local/lib/python2.7/site-packages/certbot/cli.py", line 741, in add_deprecated_argument
self.parser.add_argument, argument_name, num_args)
File "/usr/local/share/letsencrypt/env/local/lib/python2.7/site-packages/certbot/util.py", line 479, in add_deprecated_argument
configargparse.ACTION_TYPES_THAT_DONT_NEED_A_VALUE.add(ShowWarning)
AttributeError: 'tuple' object has no attribute 'add'

# Fixed code
def add_deprecated_argument(add_argument, argument_name, nargs):
    """Adds a deprecated argument with the name argument_name.

    Deprecated arguments are not shown in the help. If they are used on
    the command line, a warning is shown stating that the argument is
    deprecated and no other action is taken.

    :param callable add_argument: Function that adds arguments to an
        argument parser/group.
    :param str argument_name: Name of deprecated argument.
    :param nargs: Value for nargs when adding the argument to argparse.

    """

    class ShowWarning(argparse.Action):
        """Action to log a warning when an argument is used."""

        def __call__(self, unused1, unused2, unused3, option_string=None):
            sys.stderr.write("Use of {0} is deprecated.\n".format(option_string))

    # In version 0.12.0 ACTION_TYPES_THAT_DONT_NEED_A_VALUE was changed from a set
    # to a tuple.
    if isinstance(configargparse.ACTION_TYPES_THAT_DONT_NEED_A_VALUE, set):
        configargparse.ACTION_TYPES_THAT_DONT_NEED_A_VALUE.add(ShowWarning)
    else:
        configargparse.ACTION_TYPES_THAT_DONT_NEED_A_VALUE += (ShowWarning,)
    add_argument(argument_name, action=ShowWarning, help=argparse.SUPPRESS, nargs=nargs)