This commit is contained in:
JerryJhird 2026-05-08 21:19:26 +05:30 committed by GitHub
commit 6b5d2b171c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View file

@ -1401,7 +1401,7 @@ def banner():
if not any(_ in sys.argv for _ in ("--version", "--api")) and not conf.get("disableBanner"):
result = BANNER
if not IS_TTY or any(_ in sys.argv for _ in ("--disable-coloring", "--disable-colouring")):
if not IS_TTY or conf.get("disableColoring") or any(_ in sys.argv for _ in ("--disable-coloring", "--disable-colouring")):
result = clearColors(result)
elif IS_WIN:
coloramainit()

View file

@ -23,6 +23,9 @@ try:
class _ColorizingStreamHandler(ColorizingStreamHandler):
def colorize(self, message, levelno, force=False):
from lib.core.data import conf # import inside function to avoid ImportError
if conf.get("disableColoring"):
return message
if levelno in self.level_map and (self.is_tty or force):
bg, fg, bold = self.level_map[levelno]
params = []

View file

@ -148,6 +148,11 @@ def main():
resolveCrossReferences()
checkEnvironment()
setPaths(modulePath())
# Check for NO_COLOR environment variable
if os.environ.get("NO_COLOR") not in (None, ""):
conf.disableColoring = True
banner()
# Store original command line options for possible later restoration