(
stream: t.IO[t.Any] | None = None, color: bool | None = None
)
| 497 | |
| 498 | |
| 499 | def should_strip_ansi( |
| 500 | stream: t.IO[t.Any] | None = None, color: bool | None = None |
| 501 | ) -> bool: |
| 502 | if color is None: |
| 503 | if stream is None: |
| 504 | stream = sys.stdin |
| 505 | elif hasattr(stream, "color"): |
| 506 | # ._termui_impl.MaybeStripAnsi handles stripping ansi itself, |
| 507 | # so we don't need to strip it here |
| 508 | return False |
| 509 | return not isatty(stream) and not _is_jupyter_kernel_output(stream) |
| 510 | return not color |
| 511 | |
| 512 | |
| 513 | # On Windows, wrap the output streams with colorama to support ANSI |
no test coverage detected