From 879a6c0b1740d7a19a002fabcc29cd9499e3108b Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sun, 20 Nov 2022 23:42:22 +0000 Subject: [PATCH] Disable coloring with TERM=dumb or NO_COLOR Fixes: #1290 Related: https://no-color.org/ --- src/tox/config/cli/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 235e3a28bb..de88b61347 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -290,6 +290,8 @@ def add_color_flags(parser: ArgumentParser) -> None: converter = StrConvert() if converter.to_bool(os.environ.get("NO_COLOR", "")): color = "no" + elif os.environ.get("TERM", "") == "dumb": + color = "no" elif converter.to_bool(os.environ.get("FORCE_COLOR", "")): color = "yes" else: @@ -299,7 +301,7 @@ def add_color_flags(parser: ArgumentParser) -> None: "--colored", default=color, choices=["yes", "no"], - help="should output be enriched with colors", + help="should output be enriched with colors, default is yes unless TERM=dumb or NO_COLOR is defined.", )