From 617100c8594415c9ab3ce17237138fe928e58e01 Mon Sep 17 00:00:00 2001 From: Stephen Macke Date: Fri, 13 Dec 2024 08:11:21 -1000 Subject: [PATCH 1/4] make debugger class configurable --- ipykernel/ipkernel.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index 48efa6cd..48149439 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -23,6 +23,7 @@ from .comm.comm import BaseComm from .comm.manager import CommManager from .compiler import XCachingCompiler +from .debugger import Debugger, _is_debugpy_available from .eventloops import _use_appnope from .iostream import OutStream from .kernelbase import Kernel as KernelBase @@ -71,6 +72,8 @@ class IPythonKernel(KernelBase): shell = Instance("IPython.core.interactiveshell.InteractiveShellABC", allow_none=True) shell_class = Type(ZMQInteractiveShell) + debugger_class = Type(Debugger) + use_experimental_completions = Bool( True, help="Set this flag to False to deactivate the use of experimental IPython completion APIs.", @@ -110,11 +113,9 @@ def __init__(self, **kwargs): self.executing_blocking_code_in_main_shell = False - from .debugger import Debugger, _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, From b18b069444c9d09545e7ec76b69da67ce40d6371 Mon Sep 17 00:00:00 2001 From: Stephen Macke Date: Fri, 13 Dec 2024 19:49:55 -1000 Subject: [PATCH 2/4] address comments --- ipykernel/ipkernel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index 48149439..eb40e08f 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -23,7 +23,6 @@ from .comm.comm import BaseComm from .comm.manager import CommManager from .compiler import XCachingCompiler -from .debugger import Debugger, _is_debugpy_available from .eventloops import _use_appnope from .iostream import OutStream from .kernelbase import Kernel as KernelBase @@ -72,7 +71,9 @@ class IPythonKernel(KernelBase): shell = Instance("IPython.core.interactiveshell.InteractiveShellABC", allow_none=True) shell_class = Type(ZMQInteractiveShell) - debugger_class = Type(Debugger) + # 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") use_experimental_completions = Bool( True, @@ -113,6 +114,8 @@ def __init__(self, **kwargs): self.executing_blocking_code_in_main_shell = False + from .debugger import _is_debugpy_available + # Initialize the Debugger if _is_debugpy_available: self.debugger = self.debugger_class( From 090522dff1d11fc582f2df931cdcc6c63cb1c754 Mon Sep 17 00:00:00 2001 From: Stephen Macke Date: Sun, 15 Dec 2024 10:49:12 -0800 Subject: [PATCH 3/4] make compiler class configurable too --- ipykernel/ipkernel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index eb40e08f..c58a0ac8 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -74,6 +74,8 @@ class IPythonKernel(KernelBase): # 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, @@ -134,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] From 6bd57824e6731fbab65f71723b20a26d37e7ed46 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2024 18:49:48 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipykernel/ipkernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index c58a0ac8..5c450169 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -74,7 +74,7 @@ class IPythonKernel(KernelBase): # 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(