1212# -----------------------------------------------------------------------------
1313
1414import asyncio
15+ from typing import Any
1516
1617from jupyter_client .client import KernelClient
1718from jupyter_client .clientabc import KernelClientABC
@@ -39,11 +40,11 @@ class InProcessKernelClient(KernelClient):
3940 """
4041
4142 # The classes to use for the various channels.
42- shell_channel_class = Type (InProcessChannel ) # type:ignore[arg-type ]
43- iopub_channel_class = Type (InProcessChannel ) # type:ignore[arg-type ]
44- stdin_channel_class = Type (InProcessChannel ) # type:ignore[arg-type ]
45- control_channel_class = Type (InProcessChannel ) # type:ignore[arg-type ]
46- hb_channel_class = Type (InProcessHBChannel ) # type:ignore[arg-type ]
43+ shell_channel_class = Type (InProcessChannel ) # type:ignore[assignment ]
44+ iopub_channel_class = Type (InProcessChannel ) # type:ignore[assignment ]
45+ stdin_channel_class = Type (InProcessChannel ) # type:ignore[assignment ]
46+ control_channel_class = Type (InProcessChannel ) # type:ignore[assignment ]
47+ hb_channel_class = Type (InProcessHBChannel ) # type:ignore[assignment ]
4748
4849 kernel = Instance ("ipykernel.inprocess.ipkernel.InProcessKernel" , allow_none = True )
4950
@@ -57,9 +58,9 @@ def _default_blocking_class(self):
5758
5859 return BlockingInProcessKernelClient
5960
60- def get_connection_info (self ) :
61+ def get_connection_info (self , session : bool = False ) -> dict [ str , int | str | bytes ] :
6162 """Get the connection info for the client."""
62- d = super ().get_connection_info ()
63+ d = super ().get_connection_info (session = session )
6364 d ["kernel" ] = self .kernel # type:ignore[assignment]
6465 return d
6566
@@ -72,39 +73,45 @@ def start_channels(self, *args, **kwargs):
7273 @property
7374 def shell_channel (self ):
7475 if self ._shell_channel is None :
75- self ._shell_channel = self .shell_channel_class (self ) # type:ignore[abstract,call-arg]
76+ self ._shell_channel = self .shell_channel_class (self )
7677 return self ._shell_channel
7778
7879 @property
7980 def iopub_channel (self ):
8081 if self ._iopub_channel is None :
81- self ._iopub_channel = self .iopub_channel_class (self ) # type:ignore[abstract,call-arg]
82+ self ._iopub_channel = self .iopub_channel_class (self )
8283 return self ._iopub_channel
8384
8485 @property
8586 def stdin_channel (self ):
8687 if self ._stdin_channel is None :
87- self ._stdin_channel = self .stdin_channel_class (self ) # type:ignore[abstract,call-arg]
88+ self ._stdin_channel = self .stdin_channel_class (self )
8889 return self ._stdin_channel
8990
9091 @property
9192 def control_channel (self ):
9293 if self ._control_channel is None :
93- self ._control_channel = self .control_channel_class (self ) # type:ignore[abstract,call-arg]
94+ self ._control_channel = self .control_channel_class (self )
9495 return self ._control_channel
9596
9697 @property
9798 def hb_channel (self ):
9899 if self ._hb_channel is None :
99- self ._hb_channel = self .hb_channel_class (self ) # type:ignore[abstract,call-arg]
100+ self ._hb_channel = self .hb_channel_class (self )
100101 return self ._hb_channel
101102
102103 # Methods for sending specific messages
103104 # -------------------------------------
104105
105106 def execute (
106- self , code , silent = False , store_history = True , user_expressions = None , allow_stdin = None
107- ):
107+ self ,
108+ code : str ,
109+ silent : bool = False ,
110+ store_history : bool = True ,
111+ user_expressions : dict [str , Any ] | None = None ,
112+ allow_stdin : bool | None = None ,
113+ stop_on_error : bool = True ,
114+ ) -> str :
108115 """Execute code on the client."""
109116 if allow_stdin is None :
110117 allow_stdin = self .allow_stdin
@@ -117,7 +124,9 @@ def execute(
117124 )
118125 msg = self .session .msg ("execute_request" , content )
119126 self ._dispatch_to_kernel (msg )
120- return msg ["header" ]["msg_id" ]
127+ res = msg ["header" ]["msg_id" ]
128+ assert isinstance (res , str )
129+ return res
121130
122131 def complete (self , code , cursor_pos = None ):
123132 """Get code completion."""
0 commit comments