11from __future__ import annotations
22
33import sys
4+ from collections .abc import Callable
45from optparse import SUPPRESS_HELP , OptionParser
56
67import workflows
78import workflows .frontend
89import workflows .services
910import workflows .transport
11+ from workflows .transport .common_transport import CommonTransport
1012
1113
1214class ServiceStarter :
@@ -27,12 +29,14 @@ def on_parsing(options, args):
2729 """
2830
2931 @staticmethod
30- def on_transport_factory_preparation (transport_factory ):
32+ def on_transport_factory_preparation (
33+ transport_factory ,
34+ ) -> Callable [[], CommonTransport ] | None :
3135 """Plugin hook to intercept/manipulate newly created Transport factories
3236 before first invocation."""
3337
3438 @staticmethod
35- def on_transport_preparation (transport ) :
39+ def on_transport_preparation (transport : CommonTransport ) -> CommonTransport | None :
3640 """Plugin hook to intercept/manipulate newly created Transport objects
3741 before connecting."""
3842
@@ -136,7 +140,9 @@ def run(
136140 parser .error (f"Please specify a service name. { known_services_help } " )
137141
138142 # Create Transport factory
139- transport_factory = workflows .transport .lookup (options .transport )
143+ transport_factory : Callable [[], CommonTransport ] = workflows .transport .lookup (
144+ options .transport
145+ )
140146
141147 # Call on_transport_factory_preparation hook
142148 transport_factory = (
@@ -147,7 +153,7 @@ def run(
147153 # Set up on_transport_preparation hook to affect newly created transport objects
148154 true_transport_factory = transport_factory
149155
150- def on_transport_preparation_hook ():
156+ def on_transport_preparation_hook () -> CommonTransport :
151157 transport_object = true_transport_factory ()
152158 return self .on_transport_preparation (transport_object ) or transport_object
153159
0 commit comments