Skip to content

Commit 73482fa

Browse files
committed
add warning when a ref sidecar has anchor='right'
1 parent e58e9fd commit 73482fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sidecar/sidecar.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"""
88
TODO: Add module docstring
99
"""
10-
10+
import warnings
1111
from ipywidgets import Output, widget_serialization
12-
from traitlets import Unicode, CaselessStrEnum, Any, Instance
12+
from traitlets import Unicode, CaselessStrEnum, Any, Instance, observe
1313
from ._frontend import EXTENSION_SPEC_VERSION
1414

1515
module_name = "@jupyter-widgets/jupyterlab-sidecar"
@@ -30,3 +30,11 @@ class Sidecar(Output):
3030
).tag(sync=True)
3131
ref = Instance('sidecar.Sidecar', allow_none=True).tag(sync=True, **widget_serialization)
3232
_widget_id = Any().tag(sync=True)
33+
34+
@observe('ref')
35+
def _validate_ref_anchor(self, *args):
36+
if self.ref.anchor == 'right':
37+
warnings.warn(
38+
"`ref` cannot be set when `ref.anchor == 'right'`. "
39+
"Proceeding with `ref = None`.", UserWarning
40+
)

0 commit comments

Comments
 (0)