import functools
import warnings


def silence_warnings(func):
    """Function decorator that silences/ignores all Python warnings in the
    wrapped function.

    Example:
        >>> @silence_warnings
        >>> def foo():
        >>>     warnings.warn("this will not appear")

    """
    @functools.wraps(func)
    def inner(*args, **kwargs):
        with warnings.catch_warnings(record=True):
            warnings.simplefilter('always')
            return func(*args, **kwargs)
    return inner