Skip to content

Commit

Permalink
Add new COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS, `COLOUR_SCIENCE__F…
Browse files Browse the repository at this point in the history
…ILTER_USAGE_WARNINGS`, `COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS` and `COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS` environment variables.
  • Loading branch information
KelSolaar committed Jan 28, 2024
1 parent 378bdd0 commit cf81438
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
35 changes: 33 additions & 2 deletions colour/utilities/verbose.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Type,
cast,
)
from colour.utilities import is_string, optional
from colour.utilities import as_bool, is_string, optional

__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
Expand Down Expand Up @@ -392,7 +392,38 @@ def filter_warnings(


# Defaulting to filter *Colour* runtime warnings.
filter_warnings(colour_runtime_warnings=True)
filter_warnings(
colour_runtime_warnings=as_bool(
os.environ.get("COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS", "True")
)
)

if (
os.environ.get("COLOUR_SCIENCE__FILTER_USAGE_WARNINGS") is not None
): # pragma: no cover
filter_warnings(
colour_usage_warnings=as_bool(
os.environ["COLOUR_SCIENCE__FILTER_USAGE_WARNINGS"]
)
)

if (
os.environ.get("COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS") is not None
): # pragma: no cover
filter_warnings(
colour_usage_warnings=as_bool(
os.environ["COLOUR_SCIENCE__FILTER_WARNINGS"],
)
)

if (
os.environ.get("COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS") is not None
): # pragma: no cover
filter_warnings(
colour_usage_warnings=as_bool(
os.environ["COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS"]
)
)


@contextmanager
Expand Down
10 changes: 8 additions & 2 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Advanced Concepts
=================
Advanced Usage
==============

This page describes some advanced usage scenarios of **Colour**.

Expand Down Expand Up @@ -29,6 +29,12 @@ runtime:
:func:`warnings.showwarning` definition to be replaced with the
:func:`colour.utilities.show_warning` definition and thus providing
complete traceback from the point where the warning occurred.
- ``COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS``: Filter *Colour* runtime
warnings.
- ``COLOUR_SCIENCE__FILTER_USAGE_WARNINGS``: Filter *Colour* usage warnings.
- ``COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS``: Filter *Colour* warnings, this
also filters *Colour* usage and runtime warnings.
- ``COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS``: Filter *Python* warnings.

JEnv File
---------
Expand Down
4 changes: 2 additions & 2 deletions docs/basics.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Basic Concepts
==============
Basic Usage
===========

This page puts an emphasis on basic concepts of **Colour**, those are important
to understand.
Expand Down

0 comments on commit cf81438

Please sign in to comment.