hooks.warnings module

Provides warning hooking functionality.

@hooks.warnings.WarningHook[source]

Bases: hooks.base._HookDecorator

Fired when a warning is encountered.

The decorated function is passed the following parameters when a warning is fired:

Parameters:
  • message (Warning) – The Warning instance.
  • category (Warning) – The type of Warning that was encountered.
  • filename (str) – The name of the file where the warning was encountered.
  • lineno (int) – The line number of the file where the warning was encountered.
from hooks.warnings import WarningHook

@WarningHook
def warning_callback(message, category, filename, lineno):
    # Code...
hooks.warnings.warning_hooks

The singleton object of the _WarningHooks class.