Skip to content

Commit

Permalink
Use supported_features=['debugger'] in kernel info reply (#1296)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ianthomas23 and pre-commit-ci[bot] authored Feb 14, 2025
1 parent e6a688d commit eb0aee6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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")
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

0 comments on commit eb0aee6

Please sign in to comment.