from typing import Generator


def flatten(iterable, ignore_none=False) -> list:
    """
         Flatten an iterable completely, getting rid of None values

            Arguments:
                   iterable(Iterable):
                        the input
                   ignore_none(bool): optional
                        whether to skip None values or not. Default is False.

            Returns:
                A flattened list

                .. code-block:: python

                   flatten(
                   [
                     [[1]],
                     [[2], 3, None, (5,)],
                     []
                   ], ignore_none=True) == [1, 2, 3, 5]

        """
    res = (
        sum([flatten(x, ignore_none) for x in iterable], [])
        if isinstance(iterable, (list, tuple, Generator))
        else [iterable]
    )
    if isinstance(res, (list, tuple, Generator)) and ignore_none:
        return [x for x in res if x is not None]
    return res