Skip to content

Commit af3f310

Browse files
authored
Throw a more informative error when pydeck's .show() method doesn't return a Widget (#154)
1 parent d6684ea commit af3f310

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

shinywidgets/_as_widget.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,22 @@ def as_widget_plotly(x: object) -> Optional[Widget]:
7878
def as_widget_pydeck(x: object) -> Optional[Widget]:
7979
if not hasattr(x, "show"):
8080
raise TypeError(
81-
f"Don't know how to coerce {x} (a pydeck object) into an ipywidget without a .show() method."
81+
f"Don't know how to coerce {type(x)} (a pydeck object) into an ipywidget without a .show() method."
8282
)
8383

84-
return x.show() # type: ignore
84+
res = x.show() # type: ignore
85+
86+
if not isinstance(res, Widget):
87+
raise TypeError(
88+
"pydeck v0.9 removed ipywidgets support, thus it no longer works with "
89+
"shinywidgets. Consider either downgrading to pydeck v0.8.0 or using shiny's "
90+
"@render.ui decorator to display the map (and return Deck.to_html() in "
91+
"that render function). Note that the latter strategy means you won't be "
92+
"able to programmatically .update() the map or access user events."
93+
"For more, see https://github.com/visgl/deck.gl/pull/8854"
94+
)
95+
96+
return res # type: ignore
8597

8698

8799
AS_WIDGET_MAP = {

0 commit comments

Comments
 (0)