# Buggy code
def removed(
    name,
    requirements=None,
    bin_env=None,
    log=None,
    proxy=None,
    timeout=None,
    user=None,
    runas=None,
    cwd=None,
    __env__="base",
):
    """
    Make sure that a package is not installed.

    name
        The name of the package to uninstall
    user
        The user under which to run pip
    bin_env : None
        the pip executable or virtualenenv to use
    """
    ret = {"name": name, "result": None, "comment": "", "changes": {}}

    if runas is not None:
        # The user is using a deprecated argument, warn!
        msg = (
            "The 'runas' argument to pip.installed is deprecated, and will "
            "be removed in 0.18.0. Please use 'user' instead."
        )
        salt.utils.warn_until((0, 18), msg)
        ret.setdefault("warnings", []).append(msg)

    # "There can only be one"
    if runas is not None and user:
        raise CommandExecutionError(
            "The 'runas' and 'user' arguments are mutually exclusive. "
            "Please use 'user' as 'runas' is being deprecated."
        )
    # Support deprecated 'runas' arg
    elif runas is not None and not user:
        user = runas

    try:
        pip_list = __salt__["pip.list"](bin_env=bin_env, user=user, cwd=cwd)
    except (CommandExecutionError, CommandNotFoundError) as err:
        ret["result"] = False
        ret["comment"] = "Error uninstalling '{0}': {1}".format(name, err)
        return ret

    if name not in pip_list:
        ret["result"] = True
        ret["comment"] = "Package is not installed."
        return ret

    if __opts__["test"]:
        ret["result"] = None
        ret["comment"] = "Package {0} is set to be removed".format(name)
        return ret

    if __salt__["pip.uninstall"](
        pkgs=name,
        requirements=requirements,
        bin_env=bin_env,
        log=log,
        proxy=proxy,
        timeout=timeout,
        user=user,
        cwd=cwd,
        __env__="base",
    ):
        ret["result"] = True
        ret["changes"][name] = "Removed"
        ret["comment"] = "Package was successfully removed."
    else:
        ret["result"] = False
        ret["comment"] = "Could not remove package."
    return ret


# Traceback (AttributeError)
[ERROR   ] Error in function _master_opts:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/master.py", line 1444, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/pymodules/python2.7/salt/master.py", line 891, in _master_opts
envs = self._file_envs()
File "/usr/lib/pymodules/python2.7/salt/fileserver/__init__.py", line 153, in envs
ret.update(self.servers[fstr]())
File "/usr/lib/pymodules/python2.7/salt/fileserver/hgfs.py", line 176, in envs
tags = repo.get_tags()
AttributeError: 'hgclient' object has no attribute 'get_tags'

# Fixed code
def removed(
    name,
    requirements=None,
    bin_env=None,
    log=None,
    proxy=None,
    timeout=None,
    user=None,
    runas=None,
    cwd=None,
    __env__="base",
):
    """
    Make sure that a package is not installed.

    name
        The name of the package to uninstall
    user
        The user under which to run pip
    bin_env : None
        the pip executable or virtualenenv to use
    """
    ret = {"name": name, "result": None, "comment": "", "changes": {}}

    if runas is not None:
        # The user is using a deprecated argument, warn!
        msg = (
            "The 'runas' argument to pip.installed is deprecated, and "
            "will be removed in Salt {version}. Please use 'user' "
            "instead.".format(
                version=_SaltStackVersion.from_name("Hydrogen").formatted_version
            )
        )
        salt.utils.warn_until("Hydrogen", msg)
        ret.setdefault("warnings", []).append(msg)

    # "There can only be one"
    if runas is not None and user:
        raise CommandExecutionError(
            "The 'runas' and 'user' arguments are mutually exclusive. "
            "Please use 'user' as 'runas' is being deprecated."
        )
    # Support deprecated 'runas' arg
    elif runas is not None and not user:
        user = runas

    try:
        pip_list = __salt__["pip.list"](bin_env=bin_env, user=user, cwd=cwd)
    except (CommandExecutionError, CommandNotFoundError) as err:
        ret["result"] = False
        ret["comment"] = "Error uninstalling '{0}': {1}".format(name, err)
        return ret

    if name not in pip_list:
        ret["result"] = True
        ret["comment"] = "Package is not installed."
        return ret

    if __opts__["test"]:
        ret["result"] = None
        ret["comment"] = "Package {0} is set to be removed".format(name)
        return ret

    if __salt__["pip.uninstall"](
        pkgs=name,
        requirements=requirements,
        bin_env=bin_env,
        log=log,
        proxy=proxy,
        timeout=timeout,
        user=user,
        cwd=cwd,
        __env__="base",
    ):
        ret["result"] = True
        ret["changes"][name] = "Removed"
        ret["comment"] = "Package was successfully removed."
    else:
        ret["result"] = False
        ret["comment"] = "Could not remove package."
    return ret