On Windows, wrap stream with Colorama for ANSI style support.
| 62 | |
| 63 | |
| 64 | class _ColorStreamHandler(logging.StreamHandler): # type: ignore[type-arg] |
| 65 | """On Windows, wrap stream with Colorama for ANSI style support.""" |
| 66 | |
| 67 | def __init__(self) -> None: |
| 68 | try: |
| 69 | import colorama |
| 70 | except ImportError: |
| 71 | stream = None |
| 72 | else: |
| 73 | stream = colorama.AnsiToWin32(sys.stderr) |
| 74 | |
| 75 | super().__init__(stream) |
| 76 | |
| 77 | |
| 78 | def _log(type: str, message: str, *args: t.Any, **kwargs: t.Any) -> None: |