11import sys
22from socket import gethostname
3- from typing import Optional
3+ from typing import Optional , Tuple
44
55import cloudpickle
66import zmq
@@ -36,7 +36,7 @@ def send_dict(self, input_dict: dict):
3636 """
3737 self ._socket .send (cloudpickle .dumps (input_dict ))
3838
39- def receive_dict (self ):
39+ def receive_dict (self ) -> dict :
4040 """
4141 Receive a dictionary from a connected client process.
4242
@@ -64,7 +64,7 @@ def send_and_receive_dict(self, input_dict: dict) -> dict:
6464 self .send_dict (input_dict = input_dict )
6565 return self .receive_dict ()
6666
67- def bind_to_random_port (self ):
67+ def bind_to_random_port (self ) -> int :
6868 """
6969 Identify a random port typically in the range from 49152 to 65536 to bind the SocketInterface instance to. Other
7070 processes can then connect to this port to receive instructions and send results.
@@ -122,7 +122,7 @@ def interface_bootup(
122122 command_lst : list [str ],
123123 connections ,
124124 hostname_localhost : Optional [bool ] = None ,
125- ):
125+ ) -> SocketInterface :
126126 """
127127 Start interface for ZMQ communication
128128
@@ -161,7 +161,7 @@ def interface_bootup(
161161 return interface
162162
163163
164- def interface_connect (host : str , port : str ):
164+ def interface_connect (host : str , port : str ) -> Tuple [ zmq . Context , zmq . Socket ] :
165165 """
166166 Connect to an existing SocketInterface instance by providing the hostname and the port as strings.
167167
@@ -186,7 +186,7 @@ def interface_send(socket: zmq.Socket, result_dict: dict):
186186 socket .send (cloudpickle .dumps (result_dict ))
187187
188188
189- def interface_receive (socket : zmq .Socket ):
189+ def interface_receive (socket : zmq .Socket ) -> dict :
190190 """
191191 Receive instructions from a SocketInterface instance.
192192
0 commit comments