Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ux): get rid of duplicated tracebacks #10002

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"""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

Check warning on line 52 in ibis/expr/types/core.py

View check run for this annotation

Codecov / codecov/patch

ibis/expr/types/core.py#L51-L52

Added lines #L51 - L52 were not covered by tests
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 @@
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