Skip to content

Commit 2baa1a9

Browse files
committed
Add new COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS, COLOUR_SCIENCE__FILTER_USAGE_WARNINGS, COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS and COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS environment variables.
1 parent 070f253 commit 2baa1a9

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

colour/utilities/verbose.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Type,
3333
cast,
3434
)
35-
from colour.utilities import is_string, optional
35+
from colour.utilities import as_bool, is_string, optional
3636

3737
__author__ = "Colour Developers"
3838
__copyright__ = "Copyright 2013 Colour Developers"
@@ -392,7 +392,38 @@ def filter_warnings(
392392

393393

394394
# Defaulting to filter *Colour* runtime warnings.
395-
filter_warnings(colour_runtime_warnings=True)
395+
filter_warnings(
396+
colour_runtime_warnings=as_bool(
397+
os.environ.get("COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS", "True")
398+
)
399+
)
400+
401+
if (
402+
os.environ.get("COLOUR_SCIENCE__FILTER_USAGE_WARNINGS") is not None
403+
): # pragma: no cover
404+
filter_warnings(
405+
colour_usage_warnings=as_bool(
406+
os.environ["COLOUR_SCIENCE__FILTER_USAGE_WARNINGS"]
407+
)
408+
)
409+
410+
if (
411+
os.environ.get("COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS") is not None
412+
): # pragma: no cover
413+
filter_warnings(
414+
colour_usage_warnings=as_bool(
415+
os.environ["COLOUR_SCIENCE__FILTER_WARNINGS"],
416+
)
417+
)
418+
419+
if (
420+
os.environ.get("COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS") is not None
421+
): # pragma: no cover
422+
filter_warnings(
423+
colour_usage_warnings=as_bool(
424+
os.environ["COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS"]
425+
)
426+
)
396427

397428

398429
@contextmanager

docs/advanced.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Advanced Concepts
2-
=================
1+
Advanced Usage
2+
==============
33

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

@@ -29,6 +29,12 @@ runtime:
2929
:func:`warnings.showwarning` definition to be replaced with the
3030
:func:`colour.utilities.show_warning` definition and thus providing
3131
complete traceback from the point where the warning occurred.
32+
- ``COLOUR_SCIENCE__FILTER_RUNTIME_WARNINGS``: Filter *Colour* runtime
33+
warnings.
34+
- ``COLOUR_SCIENCE__FILTER_USAGE_WARNINGS``: Filter *Colour* usage warnings.
35+
- ``COLOUR_SCIENCE__FILTER_COLOUR_WARNINGS``: Filter *Colour* warnings, this
36+
also filters *Colour* usage and runtime warnings.
37+
- ``COLOUR_SCIENCE__FILTER_PYTHON_WARNINGS``: Filter *Python* warnings.
3238

3339
JEnv File
3440
---------

docs/basics.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Basic Concepts
2-
==============
1+
Basic Usage
2+
===========
33

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

0 commit comments

Comments
 (0)