From 7df4bdd9ffc551fe39d249b17dfd60dca1ac43e9 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:41:48 -0400 Subject: [PATCH] fix(ux): get rid of duplicated tracebacks (#10002) --- ibis/expr/types/core.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/ibis/expr/types/core.py b/ibis/expr/types/core.py index ea47f7059fd3..9c9c380b114e 100644 --- a/ibis/expr/types/core.py +++ b/ibis/expr/types/core.py @@ -46,9 +46,13 @@ class _FixedTextJupyterMixin(JupyterMixin): """JupyterMixin adds a spurious newline to text, this fixes the issue.""" def _repr_mimebundle_(self, *args, **kwargs): - bundle = super()._repr_mimebundle_(*args, **kwargs) - bundle["text/plain"] = bundle["text/plain"].rstrip() - return bundle + try: + bundle = super()._repr_mimebundle_(*args, **kwargs) + except Exception: # noqa: BLE001 + return None + else: + bundle["text/plain"] = bundle["text/plain"].rstrip() + return bundle def _capture_rich_renderable(renderable: RenderableType) -> str: @@ -110,23 +114,6 @@ def __rich_console__(self, console: Console, options): self._noninteractive_repr(), ] return Text("\n".join(lines)) - except Exception as e: - # In IPython exceptions inside of _repr_mimebundle_ are swallowed to - # allow calling several display functions and choosing to display - # the "best" result based on some priority. - # This behavior, though, means that exceptions that bubble up inside of the interactive repr - # are silently caught. - # - # We can't stop the exception from being swallowed, but we can force - # the display of that exception as we do here. - # - # A _very_ annoying caveat is that this exception is _not_ being - # ` raise`d, it is only being printed to the console. This means - # that you cannot "catch" it. - # - # This restriction is only present in IPython, not in other REPLs. - console.print_exception() - raise e return console.render(rich_object, options=options) def __init__(self, arg: ops.Node) -> None: