From 770dc94b8c6c5a83df22e39b7ab94f0f399a92fa Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 30 Jan 2025 09:28:16 -0600 Subject: [PATCH] Close #184: only call _repr_mimebundle_ if it exists and is callable --- CHANGELOG.md | 1 + shinywidgets/_shinywidgets.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e729a9..801f7ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] +* Fixes 'AttributeError: object has no attribute "_repr_mimebundle_"'. (#184) ## [0.5.0] - 2025-01-29 diff --git a/shinywidgets/_shinywidgets.py b/shinywidgets/_shinywidgets.py index 51fe713..6bc64c6 100644 --- a/shinywidgets/_shinywidgets.py +++ b/shinywidgets/_shinywidgets.py @@ -125,7 +125,8 @@ def _open_shiny_comm(): # Call _repr_mimebundle_() before get_state() since it may modify the widget # in an important way (unfortunately, it does for plotly) # # https://github.com/plotly/plotly.py/blob/0089f32/packages/python/plotly/plotly/basewidget.py#L734-L738 - w._repr_mimebundle_() + if hasattr(w, "_repr_mimebundle_") and callable(w._repr_mimebundle_): + w._repr_mimebundle_() # Now, get the state state, buffer_paths, buffers = _remove_buffers(w.get_state())