Skip to content

Commit

Permalink
fix(ux): get rid of duplicated tracebacks (#10002)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Sep 3, 2024
1 parent 7a6af8d commit 7df4bdd
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions ibis/expr/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7df4bdd

Please sign in to comment.