1111# Imports
1212# -----------------------------------------------------------------------------
1313
14+
15+ from typing import Any
16+
1417from jupyter_client .client import KernelClient
1518from jupyter_client .clientabc import KernelClientABC
1619
@@ -54,9 +57,9 @@ def _default_blocking_class(self):
5457
5558 return BlockingInProcessKernelClient
5659
57- def get_connection_info (self ):
60+ def get_connection_info (self , session : bool = False ):
5861 """Get the connection info for the client."""
59- d = super ().get_connection_info ()
62+ d = super ().get_connection_info (session = session )
6063 d ["kernel" ] = self .kernel # type:ignore[assignment]
6164 return d
6265
@@ -99,9 +102,18 @@ def hb_channel(self):
99102 # Methods for sending specific messages
100103 # -------------------------------------
101104
102- async def execute (
103- self , code , silent = False , store_history = True , user_expressions = None , allow_stdin = None
104- ):
105+ # Feb 2025: superclass in jupyter-Client is sync,
106+ # it should likely be made all consistent and push
107+ # jupyter_client async as well
108+ async def execute ( # type:ignore [override]
109+ self ,
110+ code : str ,
111+ silent : bool = False ,
112+ store_history : bool = True ,
113+ user_expressions : dict [str , Any ] | None = None ,
114+ allow_stdin : bool | None = None ,
115+ stop_on_error : bool = True ,
116+ ) -> str :
105117 """Execute code on the client."""
106118 if allow_stdin is None :
107119 allow_stdin = self .allow_stdin
@@ -114,7 +126,9 @@ async def execute(
114126 )
115127 msg = self .session .msg ("execute_request" , content )
116128 await self ._dispatch_to_kernel (msg )
117- return msg ["header" ]["msg_id" ]
129+ res = msg ["header" ]["msg_id" ]
130+ assert isinstance (res , str )
131+ return res
118132
119133 async def complete (self , code , cursor_pos = None ):
120134 """Get code completion."""
0 commit comments