Add support for NO_COLOR and FORCE_COLOR (#7466)

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
Hugo van Kemenade
2020-07-10 14:49:10 +03:00
committed by GitHub
parent 2ae721cda5
commit c1c5a2b34a
4 changed files with 61 additions and 14 deletions

View File

@@ -27,11 +27,12 @@ def should_do_markup(file: TextIO) -> bool:
return True
if os.environ.get("PY_COLORS") == "0":
return False
if "NO_COLOR" in os.environ:
return False
if "FORCE_COLOR" in os.environ:
return True
return (
hasattr(file, "isatty")
and file.isatty()
and os.environ.get("TERM") != "dumb"
and not (sys.platform.startswith("java") and os._name == "nt")
hasattr(file, "isatty") and file.isatty() and os.environ.get("TERM") != "dumb"
)