skoot.decorators.suppress_warnings

skoot.decorators.suppress_warnings(func)[source][source]

Force a method to suppress all warnings it may raise.

This decorator should be used with caution, as it may complicate debugging. For internal purposes, this is used for imports that cause consistent warnings (like pandas or matplotlib)

Parameters:

func : callable

Automatically passed to the decorator. This function is run within the context of the warning filterer.

Examples

When any function is decorated with the suppress_warnings decorator, any warnings that are raised will be suppressed.

>>> import warnings
>>>
>>> @suppress_warnings
... def fun_that_warns():
...     warnings.warn("This is a warning", UserWarning)
...     return 1
>>>
>>> fun_that_warns()
1