(file: TextIO)
| 34 | |
| 35 | |
| 36 | def should_do_markup(file: TextIO) -> bool: |
| 37 | if os.environ.get("PY_COLORS") == "1": |
| 38 | return True |
| 39 | if os.environ.get("PY_COLORS") == "0": |
| 40 | return False |
| 41 | if os.environ.get("NO_COLOR"): |
| 42 | return False |
| 43 | if os.environ.get("FORCE_COLOR"): |
| 44 | return True |
| 45 | return ( |
| 46 | hasattr(file, "isatty") and file.isatty() and os.environ.get("TERM") != "dumb" |
| 47 | ) |
| 48 | |
| 49 | |
| 50 | @final |