Add support for NO_COLOR and FORCE_COLOR (#7466)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2ae721cda5
commit
c1c5a2b34a
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user