diff --git a/ibis/expr/types/core.py b/ibis/expr/types/core.py index d4eeb48989394..de645aa4fa4ac 100644 --- a/ibis/expr/types/core.py +++ b/ibis/expr/types/core.py @@ -33,10 +33,12 @@ from ibis.expr.visualize import EdgeAttributeGetter, NodeAttributeGetter -def _capture_rich_renderable(renderable: RenderableType) -> str: - from rich import get_console +def _capture_rich_renderable( + renderable: RenderableType, *, force_terminal: bool | None = None +) -> str: + from rich.console import Console - console = get_console() + console = Console(force_terminal=force_terminal) with console.capture() as capture: console.print(renderable) return capture.get().rstrip() @@ -58,7 +60,7 @@ def _noninteractive_repr(self) -> str: def __repr__(self) -> str: if opts.interactive: - return _capture_rich_renderable(self) + return _capture_rich_renderable(self, force_terminal=False) else: return self._noninteractive_repr()