44import os
55from collections import defaultdict
66from pathlib import Path
7- from typing import Callable
7+ from typing import Any
8+ from typing import ClassVar
9+ from typing import Generic
810from typing import Literal
911from typing import overload
10- from typing import Type
12+ from typing import TypeVar
1113
1214from msgspec import ValidationError
1315from msgspec .yaml import decode as yaml_decode
1618from pioreactor import types as pt
1719from pioreactor .utils import local_persistent_storage
1820from pioreactor .whoami import is_testing_env
19- from typing import Generic , TypeVar , Literal
2021
2122
2223if not is_testing_env ():
2829Device = TypeVar ("Device" , bound = str )
2930ProtocolName = str
3031
31- calibration_protocols : dict [Device , dict [ProtocolName , Type [CalibrationProtocol ]]] = defaultdict (dict )
32+ calibration_protocols : dict [str , dict [ProtocolName , type [CalibrationProtocol [ Any ] ]]] = defaultdict (dict )
3233
3334
3435class CalibrationProtocol (Generic [Device ]):
35- protocol_name : ProtocolName
36- target_device : Device | list [Device ]
37- description = ""
36+ protocol_name : ClassVar [ ProtocolName ]
37+ target_device : ClassVar [ str | list [str ] ]
38+ description : ClassVar [ str ] = ""
3839
3940 def __init_subclass__ (cls , ** kwargs ):
4041 super ().__init_subclass__ (** kwargs )
@@ -46,9 +47,7 @@ def __init_subclass__(cls, **kwargs):
4647 else :
4748 raise ValueError ("target_device must be a string or a list of strings" )
4849
49- def run (
50- self , target_device : str , * args , ** kwargs
51- ) -> structs .CalibrationBase | list [structs .CalibrationBase ]:
50+ def run (self , target_device : Device ) -> structs .CalibrationBase | list [structs .CalibrationBase ]:
5251 raise NotImplementedError ("Subclasses must implement this method." )
5352
5453
@@ -80,18 +79,20 @@ class DurationBasedPumpProtocol(CalibrationProtocol[pt.PumpCalibrationDevices]):
8079 target_device = pt .PUMP_DEVICES
8180 protocol_name = "duration_based"
8281
83- def run (self , target_device : pt .PumpCalibrationDevices , ** kwargs ) -> structs .SimplePeristalticPumpCalibration :
82+ def run (
83+ self , target_device : pt .PumpCalibrationDevices , ** kwargs
84+ ) -> structs .SimplePeristalticPumpCalibration :
8485 from pioreactor .calibrations .pump_calibration import run_pump_calibration
8586
8687 return run_pump_calibration (target_device )
8788
8889
89- class DCBasedStirringProtocol (CalibrationProtocol [Device ]):
90+ class DCBasedStirringProtocol (CalibrationProtocol [Literal [ "stirring" ] ]):
9091 target_device = "stirring"
9192 protocol_name = "dc_based"
9293
9394 def run (
94- self , target_device : Device , min_dc : str | None = None , max_dc : str | None = None
95+ self , target_device : Literal [ "stirring" ] , min_dc : str | None = None , max_dc : str | None = None
9596 ) -> structs .SimpleStirringCalibration :
9697 from pioreactor .calibrations .stirring_calibration import run_stirring_calibration
9798
0 commit comments