Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make debugger class configurable #1307

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -110,11 +116,11 @@ def __init__(self, **kwargs):

self.executing_blocking_code_in_main_shell = False

from .debugger import Debugger, _is_debugpy_available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like #1223 intentionally introduced this lazy import. Let's make sure we're addressing the need there as well before making this an eager import at the top of the file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, does this change mean that python -m ipykernel install --sys-prefix has spurious warnings?

Copy link
Member

@jasongrout jasongrout Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @krassowski who made this lazy import change earlier this year.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting, yes this is intentional to address #1198

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,
Expand All @@ -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]

Expand Down
Loading