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

Throw a more informative error when pydeck's .show() method doesn't return a Widget #154

Merged
merged 1 commit into from
Jul 31, 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
16 changes: 14 additions & 2 deletions shinywidgets/_as_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,22 @@ def as_widget_plotly(x: object) -> Optional[Widget]:
def as_widget_pydeck(x: object) -> Optional[Widget]:
if not hasattr(x, "show"):
raise TypeError(
f"Don't know how to coerce {x} (a pydeck object) into an ipywidget without a .show() method."
f"Don't know how to coerce {type(x)} (a pydeck object) into an ipywidget without a .show() method."
)

return x.show() # type: ignore
res = x.show() # type: ignore

if not isinstance(res, Widget):
raise TypeError(
"pydeck v0.9 removed ipywidgets support, thus it no longer works with "
"shinywidgets. Consider either downgrading to pydeck v0.8.0 or using shiny's "
"@render.ui decorator to display the map (and return Deck.to_html() in "
"that render function). Note that the latter strategy means you won't be "
"able to programmatically .update() the map or access user events."
"For more, see https://github.com/visgl/deck.gl/pull/8854"
)

return res # type: ignore


AS_WIDGET_MAP = {
Expand Down
Loading