Skip to content

Commit 56e9396

Browse files
authored
Make non-numeric non-empty FORCE_COLOR truthy (#14140)
Fixes #14139
1 parent 6cd8e00 commit 56e9396

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,11 @@ def parse_gray_color(cup: bytes) -> str:
520520

521521

522522
def should_force_color() -> bool:
523-
return bool(int(os.getenv("MYPY_FORCE_COLOR", os.getenv("FORCE_COLOR", "0"))))
523+
env_var = os.getenv("MYPY_FORCE_COLOR", os.getenv("FORCE_COLOR", "0"))
524+
try:
525+
return bool(int(env_var))
526+
except ValueError:
527+
return bool(env_var)
524528

525529

526530
class FancyFormatter:

0 commit comments

Comments
 (0)