Disable highlighting of primitives

This commit prevents rich from highlighting python-looking syntax like numbers,
arrays, 'None' etc.
This commit is contained in:
Joscha 2021-05-13 19:47:44 +02:00
parent 94d6a01cca
commit e3ee4e515d

View File

@ -3,6 +3,7 @@ from contextlib import asynccontextmanager, contextmanager
from types import TracebackType from types import TracebackType
from typing import AsyncIterator, Iterator, List, Optional, Type from typing import AsyncIterator, Iterator, List, Optional, Type
from rich.console import Console
from rich.progress import Progress, TaskID from rich.progress import Progress, TaskID
@ -22,9 +23,11 @@ class TerminalConductor:
def __init__(self) -> None: def __init__(self) -> None:
self._stopped = False self._stopped = False
self._lock = asyncio.Lock() self._lock = asyncio.Lock()
self._progress = Progress()
self._lines: List[str] = [] self._lines: List[str] = []
self._console = Console(highlight=False)
self._progress = Progress(console=self._console)
async def _start(self) -> None: async def _start(self) -> None:
for task in self._progress.tasks: for task in self._progress.tasks:
task.visible = True task.visible = True
@ -61,7 +64,7 @@ class TerminalConductor:
if self._stopped: if self._stopped:
self._lines.append(line) self._lines.append(line)
else: else:
self._progress.console.print(line) self._console.print(line)
@asynccontextmanager @asynccontextmanager
async def exclusive_output(self) -> AsyncIterator[None]: async def exclusive_output(self) -> AsyncIterator[None]: