Skip to content

Commit

Permalink
fix: use comm package in backwards compatible way
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Nov 23, 2022
1 parent 1cf06b1 commit 736cb99
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions ipykernel/comm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__all__ = ["Comm", "CommManager"]

from comm.base_comm import CommManager # noqa

from .comm import Comm # noqa
from .manager import CommManager
8 changes: 5 additions & 3 deletions ipykernel/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import traitlets.config
from comm.base_comm import BaseComm

from ipykernel.jsonutil import json_clean
from ipykernel.kernelbase import Kernel


class Comm(BaseComm):
class Comm(traitlets.config.LoggingConfigurable, BaseComm):
"""Class for communicating between a Frontend and a Kernel"""

def __init__(self, *args, **kwargs):
self.kernel = None

super().__init__(*args, **kwargs)
# Comm takes positional arguments, LoggingConfigurable does not, so we explicitly forward arguments
traitlets.config.LoggingConfigurable.__init__(self, **kwargs)
BaseComm.__init__(self, *args, **kwargs)

def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
"""Helper for sending a comm message on IOPub"""
Expand Down
11 changes: 10 additions & 1 deletion ipykernel/comm/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,13 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from comm.base_comm import CommManager # noqa

import comm.base_comm
import traitlets.config


class CommManager(traitlets.config.LoggingConfigurable, comm.base_comm.CommManager):
def __init__(self, **kwargs):
# CommManager doesn't take arguments, so we explicitly forward arguments
traitlets.config.LoggingConfigurable.__init__(self, **kwargs)
comm.base_comm.CommManager.__init__(self)

0 comments on commit 736cb99

Please sign in to comment.