colour.utilities.filter_warnings#

colour.utilities.filter_warnings(colour_runtime_warnings: Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]] = None, colour_usage_warnings: Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]] = None, colour_warnings: Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]] = None, python_warnings: Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]] = 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 (Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]]) – Whether to filter Colour runtime warnings according to the action value.

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

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

  • python_warnings (Optional[Union[bool, Literal['default', 'error', 'ignore', 'always', 'module', 'once']]]) – 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)