import six


def compact(seq):
    """
    Removes ``None`` values from various sequence-based data structures.

    dict:
        Removes keys with a corresponding ``None`` value.

    list:
        Removes ``None`` values.

    >>> compact({'foo': 'bar', 'baz': None})
    {'foo': 'bar'}

    >>> compact([1, None, 2])
    [1, 2]
    """
    if isinstance(seq, dict):
        return {k: v for k, v in six.iteritems(seq) if v is not None}

    elif isinstance(seq, list):
        return [k for k in seq if k is not None]