from typing import Iterable
from typing import Mapping


def list_wrap(data, wrap_strings=True, coerce_iterables=False):
    """
    Wraps ``data`` in a list if it is not inherantly iterable, or is a string or mapping.
    If ``wrap_strings`` is set to False, then strings will be left as-is.
    If ``coerce_iterables`` is True, then non-mapping iterables will be forced to a list type
    instead of being passed through.
    """
    is_string = isinstance(data, str)
    is_iterable = isinstance(data, Iterable)
    is_mapping = isinstance(data, Mapping)
    if is_iterable and not is_mapping and not is_string:
        if coerce_iterables:
            data = list(data)
    elif not is_string or wrap_strings:
        data = [data]
    return data