diff --git a/ipykernel/kernelbase.py b/ipykernel/kernelbase.py index d496e0c9..17d0d6cf 100644 --- a/ipykernel/kernelbase.py +++ b/ipykernel/kernelbase.py @@ -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.""" diff --git a/tests/test_debugger.py b/tests/test_debugger.py index fa64d2d0..4646fb49 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -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"}