Skip to content

Commit eb0aee6

Browse files
Use supported_features=['debugger'] in kernel info reply (#1296)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e6a688d commit eb0aee6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

ipykernel/kernelbase.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -880,18 +880,23 @@ async def connect_request(self, socket, ident, parent):
880880

881881
@property
882882
def kernel_info(self):
883-
info = {
883+
from .debugger import _is_debugpy_available
884+
885+
supported_features: list[str] = []
886+
if self._supports_kernel_subshells:
887+
supported_features.append("kernel subshells")
888+
if _is_debugpy_available:
889+
supported_features.append("debugger")
890+
891+
return {
884892
"protocol_version": kernel_protocol_version,
885893
"implementation": self.implementation,
886894
"implementation_version": self.implementation_version,
887895
"language_info": self.language_info,
888896
"banner": self.banner,
889897
"help_links": self.help_links,
890-
"supported_features": [],
898+
"supported_features": supported_features,
891899
}
892-
if self._supports_kernel_subshells:
893-
info["supported_features"] = ["kernel subshells"]
894-
return info
895900

896901
async def kernel_info_request(self, socket, ident, parent):
897902
"""Handle a kernel info request."""

tests/test_debugger.py

+11
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ def test_debug_initialize(kernel):
9696
assert reply == {}
9797

9898

99+
def test_supported_features(kernel_with_debug):
100+
kernel_with_debug.kernel_info()
101+
reply = kernel_with_debug.get_shell_msg(timeout=TIMEOUT)
102+
supported_features = reply["content"]["supported_features"]
103+
104+
if debugpy:
105+
assert "debugger" in supported_features
106+
else:
107+
assert "debugger" not in supported_features
108+
109+
99110
def test_attach_debug(kernel_with_debug):
100111
reply = wait_for_debug_request(
101112
kernel_with_debug, "evaluate", {"expression": "'a' + 'b'", "context": "repl"}

0 commit comments

Comments
 (0)