from typing import Mapping


def parse_kv_list(params):
    """Create a dict from a "key=value" list.

    Parameters
    ----------
    params : sequence of str or mapping
        For a sequence, each item should have the form "<key>=<value".  If
        `params` is a mapping, it will be returned as is.

    Returns
    -------
    A mapping from backend key to value.

    Raises
    ------
    ValueError if item in `params` does not match expected "key=value" format.
    """
    if isinstance(params, Mapping):
        res = params
    elif params:
        def check_fmt(item):
            if "=" not in item:
                raise ValueError(
                    "Expected 'key=value' format but got '{}'"
                    .format(item))
            return item

        res = dict(p.split("=", 1) for p in map(check_fmt, params))
    else:
        res = {}
    return res