Skip to content

Commit 309b829

Browse files
feat: provide a default implementation (#13)
The default implementation does nothing, but allows ipywidgets to be used without a kernel. This is a common use case in testing/CI.
1 parent b39a369 commit 309b829

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

comm/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
It also provides a base Comm implementation and a default CommManager for the IPython case.
99
"""
1010

11-
from .base_comm import CommManager
11+
from .base_comm import BaseComm, CommManager
1212

1313
__version__ = "0.1.2"
1414
__all__ = [
@@ -20,12 +20,17 @@
2020
_comm_manager = None
2121

2222

23+
class DummyComm(BaseComm):
24+
def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
25+
pass
26+
27+
2328
def _create_comm(*args, **kwargs):
2429
"""Create a Comm.
2530
2631
This method is intended to be replaced, so that it returns your Comm instance.
2732
"""
28-
raise NotImplementedError("Cannot ")
33+
return DummyComm(*args, **kwargs)
2934

3035

3136
def _get_comm_manager():

0 commit comments

Comments
 (0)