colour.utilities.show_warning#

colour.utilities.show_warning(message: Union[Warning, str], category: Type[Warning], filename: str, lineno: int, file: Optional[TextIO] = None, line: Optional[str] = None) None[source]#

Alternative warnings.showwarning() definition that allows traceback printing.

This definition is expected to be used by setting the COLOUR_SCIENCE__COLOUR__SHOW_WARNINGS_WITH_TRACEBACK environment variable prior to importing colour.

Parameters:
  • message (Union[Warning, str]) – Warning message.

  • category (Type[Warning]) – Warning sub-class.

  • filename (str) – File path to read the line at lineno from if line is None.

  • lineno (int) – Line number to read the line at in filename if line is None.

  • file (Optional[TextIO]) – file object to write the warning to, defaults to sys.stderr attribute.

  • line (Optional[str]) – Source code to be included in the warning message.

Return type:

None

Notes

  • Setting the COLOUR_SCIENCE__COLOUR__SHOW_WARNINGS_WITH_TRACEBACK environment variable will result in the warnings.showwarning() definition to be replaced with the colour.utilities.show_warning() definition and thus providing complete traceback from the point where the warning occurred.