# Buggy code
def _mixin_setup(self):
    salt.utils.warn_until(
        "Nitrogen",
        "Please stop sub-classing PidfileMix and instead subclass "
        "DaemonMixIn which contains the same behavior. PidfileMixin "
        "will be supported until Salt {version}.",
    )
    self.add_option(
        "--pid-file",
        dest="pidfile",
        default=os.path.join(
            syspaths.PIDFILE_DIR, "{0}.pid".format(self.get_prog_name())
        ),
        help=("Specify the location of the pidfile. Default: %default"),
    )


# Traceback (optparse.OptionConflictError)
/usr/lib/python2.7/dist-packages/salt/utils/parsers.py:953: DeprecationWarning: Please stop sub-classing PidfileMix and instead subclass DaemonMixIn which contains the same behavior. PidfileMixin will be supported until Salt Nitrogen (Unreleased).
Traceback (most recent call last):
File "/usr/bin/salt-api", line 8, in <module>
salt_api()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 441, in salt_api
sapi = salt.cli.api.SaltAPI()  # pylint: disable=E1120
File "/usr/lib/python2.7/dist-packages/salt/utils/parsers.py", line 152, in __init__
optparse.OptionParser.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/optparse.py", line 1220, in __init__
add_help=add_help_option)
File "/usr/lib/python2.7/dist-packages/salt/utils/parsers.py", line 233, in _populate_option_list
mixin_setup_func(self)
File "/usr/lib/python2.7/dist-packages/salt/utils/parsers.py", line 962, in _mixin_setup
help=('Specify the location of the pidfile. Default: %default')
File "/usr/lib/python2.7/optparse.py", line 1021, in add_option
self._check_conflict(option)
File "/usr/lib/python2.7/optparse.py", line 996, in _check_conflict
option)
optparse.OptionConflictError: option --pid-file: conflicting option string(s): --pid-file

# Fixed code
def _mixin_setup(self):
    salt.utils.warn_until(
        "Nitrogen",
        "Please stop sub-classing PidfileMix and instead subclass "
        "DaemonMixIn which contains the same behavior. PidfileMixin "
        "will be supported until Salt {version}.",
    )
    try:
        self.add_option(
            "--pid-file",
            dest="pidfile",
            default=os.path.join(
                syspaths.PIDFILE_DIR, "{0}.pid".format(self.get_prog_name())
            ),
            help=("Specify the location of the pidfile. Default: %default"),
        )

        # Since there was no colision with DaemonMixin, let's add the
        # pidfile mixin methods. This is used using types.MethodType
        # because if we had defined these at the class level, they would
        # have overridden the exact same methods from the DaemonMixin.

        def set_pidfile(self):
            from salt.utils.process import set_pidfile

            set_pidfile(self.config["pidfile"], self.config["user"])

        self.set_pidfile = types.MethodType(set_pidfile, self)

        def check_pidfile(self):
            """
            Report whether a pidfile exists
            """
            from salt.utils.process import check_pidfile

            return check_pidfile(self.config["pidfile"])

        self.check_pidfile = types.MethodType(check_pidfile, self)

        def get_pidfile(self):
            """
            Return a pid contained in a pidfile
            """
            from salt.utils.process import get_pidfile

            return get_pidfile(self.config["pidfile"])

        self.get_pidfile = types.MethodType(get_pidfile, self)
    except optparse.OptionConflictError:
        # The option was already added by the DaemonMixin
        pass