colour.utilities.filter_warnings#

colour.utilities.filter_warnings(colour_runtime_warnings: bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None = None, colour_usage_warnings: bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None = None, colour_warnings: bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None = None, python_warnings: bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None = None)[source]#

Filter Colour and also optionally overall Python warnings.

The possible values for all the actions, i.e. each argument, are as follows:

  • None (No action is taken)

  • True (ignore)

  • False (default)

  • error

  • ignore

  • always

  • default

  • module

  • once

Parameters:
  • colour_runtime_warnings (bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None) – Whether to filter Colour runtime warnings according to the action value.

  • colour_usage_warnings (bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None) – Whether to filter Colour usage warnings according to the action value.

  • colour_warnings (bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None) – Whether to filter Colour warnings, this also filters Colour usage and runtime warnings according to the action value.

  • python_warnings (bool | Literal['default', 'error', 'ignore', 'always', 'module', 'once'] | None) – Whether to filter Python warnings according to the action value.

Examples

Filtering Colour runtime warnings:

>>> filter_warnings(colour_runtime_warnings=True)

Filtering Colour usage warnings:

>>> filter_warnings(colour_usage_warnings=True)

Filtering Colour warnings:

>>> filter_warnings(colour_warnings=True)

Filtering all the Colour and also Python warnings:

>>> filter_warnings(python_warnings=True)

Enabling all the Colour and Python warnings:

>>> filter_warnings(*[False] * 4)

Enabling all the Colour and Python warnings using the default action:

>>> filter_warnings(*["default"] * 4)

Setting back the default state:

>>> filter_warnings(colour_runtime_warnings=True)