From 72e596a63ced07d59b3d4d356c4962d7f999c040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 25 Oct 2024 18:18:48 +0200 Subject: [PATCH] refactor: Remove try/except import for popup functionality (#6423) --- holoviews/plotting/bokeh/callbacks.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/holoviews/plotting/bokeh/callbacks.py b/holoviews/plotting/bokeh/callbacks.py index f58489be50..865f4cd524 100644 --- a/holoviews/plotting/bokeh/callbacks.py +++ b/holoviews/plotting/bokeh/callbacks.py @@ -23,11 +23,6 @@ from panel.io.state import set_curdoc, state from panel.pane import panel -try: - from bokeh.models import XY, Panel -except Exception: - Panel = XY = None - from ...core.data import Dataset from ...core.options import CallbackError from ...core.util import ( @@ -73,7 +68,10 @@ Tap, ) from ...util.warnings import warn -from .util import BOKEH_GE_3_3_0, convert_timestamp +from .util import BOKEH_GE_3_3_0, BOKEH_GE_3_4_0, convert_timestamp + +if BOKEH_GE_3_4_0: + from bokeh.models import XY, Panel as BokehPanel POPUP_POSITION_ANCHOR = { "top_right": "bottom_left", @@ -595,7 +593,7 @@ def initialize(self, plot_id=None): stream = self.streams[0] if not getattr(stream, 'popup', None): return - elif Panel is None: + elif not BOKEH_GE_3_4_0: raise VersionError("Popup requires Bokeh >= 3.4") close_button = Button(label="", stylesheets=[r""" @@ -623,7 +621,7 @@ def initialize(self, plot_id=None): """], css_classes=["popup-close-btn"]) self._popup_position = stream.popup_position - self._panel = Panel( + self._panel = BokehPanel( position=XY(x=np.nan, y=np.nan), anchor=stream.popup_anchor or POPUP_POSITION_ANCHOR[self._popup_position], elements=[close_button],