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

Use supported_features=['debugger'] in kernel info reply #1296

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,18 +880,23 @@ async def connect_request(self, socket, ident, parent):

@property
def kernel_info(self):
info = {
from .debugger import _is_debugpy_available

supported_features: list[str] = []
if self._supports_kernel_subshells:
supported_features.append("kernel subshells")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to have "kernel", or could we just put "subshells"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if _is_debugpy_available:
supported_features.append("debugger")

return {
"protocol_version": kernel_protocol_version,
"implementation": self.implementation,
"implementation_version": self.implementation_version,
"language_info": self.language_info,
"banner": self.banner,
"help_links": self.help_links,
"supported_features": [],
"supported_features": supported_features,
}
if self._supports_kernel_subshells:
info["supported_features"] = ["kernel subshells"]
return info

async def kernel_info_request(self, socket, ident, parent):
"""Handle a kernel info request."""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ def test_debug_initialize(kernel):
assert reply == {}


def test_supported_features(kernel_with_debug):
kernel_with_debug.kernel_info()
reply = kernel_with_debug.get_shell_msg(timeout=TIMEOUT)
supported_features = reply["content"]["supported_features"]

if debugpy:
assert "debugger" in supported_features
else:
assert "debugger" not in supported_features


def test_attach_debug(kernel_with_debug):
reply = wait_for_debug_request(
kernel_with_debug, "evaluate", {"expression": "'a' + 'b'", "context": "repl"}
Expand Down
Loading