diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index 48efa6cd..5c450169 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -71,6 +71,12 @@ class IPythonKernel(KernelBase): shell = Instance("IPython.core.interactiveshell.InteractiveShellABC", allow_none=True) shell_class = Type(ZMQInteractiveShell) + # use fully-qualified name to ensure lazy import and prevent the issue from + # https://github.com/ipython/ipykernel/issues/1198 + debugger_class = Type("ipykernel.debugger.Debugger") + + compiler_class = Type(XCachingCompiler) + use_experimental_completions = Bool( True, help="Set this flag to False to deactivate the use of experimental IPython completion APIs.", @@ -110,11 +116,11 @@ def __init__(self, **kwargs): self.executing_blocking_code_in_main_shell = False - from .debugger import Debugger, _is_debugpy_available + from .debugger import _is_debugpy_available # Initialize the Debugger if _is_debugpy_available: - self.debugger = Debugger( + self.debugger = self.debugger_class( self.log, self.debugpy_socket, self._publish_debug_event, @@ -130,7 +136,7 @@ def __init__(self, **kwargs): user_module=self.user_module, user_ns=self.user_ns, kernel=self, - compiler_class=XCachingCompiler, + compiler_class=self.compiler_class, ) self.shell.displayhook.session = self.session # type:ignore[attr-defined]