diff --git a/ipykernel/kernelbase.py b/ipykernel/kernelbase.py index 5e6c2013..fc6106a9 100644 --- a/ipykernel/kernelbase.py +++ b/ipykernel/kernelbase.py @@ -880,6 +880,8 @@ async def connect_request(self, socket, ident, parent): @property def kernel_info(self): + from .debugger import _is_debugpy_available + info = { "protocol_version": kernel_protocol_version, "implementation": self.implementation, @@ -887,16 +889,14 @@ def kernel_info(self): "language_info": self.language_info, "banner": self.banner, "help_links": self.help_links, - "supported_features": [], } + supported_features: list[str] = [] if self._supports_kernel_subshells: - info["supported_features"] = ["kernel subshells"] - - from .debugger import _is_debugpy_available - + supported_features.append("kernel subshells") if _is_debugpy_available: - info["supported_features"].append("debugger") - + supported_features.append("debugger") + if len(supported_features) > 0: + info["supported_features"] = supported_features return info async def kernel_info_request(self, socket, ident, parent):