(text: str, colorize: bool = True)
| 30 | |
| 31 | |
| 32 | def _colorize(text: str, colorize: bool = True) -> str: |
| 33 | # pylint: disable=no-name-in-module |
| 34 | if not colorize or not sys.stdout.isatty() or not _tty_supports_color(): |
| 35 | return text |
| 36 | try: |
| 37 | from pygments import highlight # noqa: PLC0415 |
| 38 | except ImportError: |
| 39 | return text |
| 40 | from pygments.formatters import TerminalFormatter # noqa: PLC0415 |
| 41 | from pygments.lexers import PythonLexer # noqa: PLC0415 |
| 42 | |
| 43 | return highlight(text, PythonLexer(), TerminalFormatter()) |
| 44 | |
| 45 | |
| 46 | def pformat(obj: Any, *args: Any, **kwargs: Any) -> str: |
no test coverage detected