colour.utilities.show_warning#

colour.utilities.show_warning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = None, line: str | None = 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 (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 (TextIO | None) – file object to write the warning to, defaults to sys.stderr attribute.

  • line (str | None) – 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.