4
4
from datetime import datetime
5
5
from enum import Enum
6
6
from dataclasses import dataclass
7
- from pydantic import BaseModel , Field , validator
7
+ from pydantic import (
8
+ BaseModel ,
9
+ Field ,
10
+ StrictBool ,
11
+ StrictFloat ,
12
+ StrictInt ,
13
+ StrictStr ,
14
+ validator ,
15
+ )
8
16
from typing import Optional , Union , List , Dict , Any , NamedTuple , Tuple , FrozenSet
9
17
from typing_extensions import Literal , TypeGuard
10
18
@@ -877,12 +885,14 @@ def from_hw_state(cls, state: HwTipStateType) -> "TipPresenceStatus":
877
885
class RTPBase (BaseModel ):
878
886
"""Parameters defined in a protocol."""
879
887
880
- displayName : str = Field (..., description = "Display string for the parameter." )
881
- variableName : str = Field (..., description = "Python variable name of the parameter." )
882
- description : Optional [str ] = Field (
888
+ displayName : StrictStr = Field (..., description = "Display string for the parameter." )
889
+ variableName : StrictStr = Field (
890
+ ..., description = "Python variable name of the parameter."
891
+ )
892
+ description : Optional [StrictStr ] = Field (
883
893
None , description = "Detailed description of the parameter."
884
894
)
885
- suffix : Optional [str ] = Field (
895
+ suffix : Optional [StrictStr ] = Field (
886
896
None ,
887
897
description = "Units (like mL, mm/sec, etc) or a custom suffix for the parameter." ,
888
898
)
@@ -894,17 +904,17 @@ class NumberParameter(RTPBase):
894
904
type : Literal ["int" , "float" ] = Field (
895
905
..., description = "String specifying whether the number is an int or float type."
896
906
)
897
- min : float = Field (
907
+ min : Union [ StrictInt , StrictFloat ] = Field (
898
908
..., description = "Minimum value that the number param is allowed to have."
899
909
)
900
- max : float = Field (
910
+ max : Union [ StrictInt , StrictFloat ] = Field (
901
911
..., description = "Maximum value that the number param is allowed to have."
902
912
)
903
- value : float = Field (
913
+ value : Union [ StrictInt , StrictFloat ] = Field (
904
914
...,
905
915
description = "The value assigned to the parameter; if not supplied by the client, will be assigned the default value." ,
906
916
)
907
- default : float = Field (
917
+ default : Union [ StrictInt , StrictFloat ] = Field (
908
918
...,
909
919
description = "Default value of the parameter, to be used when there is no client-specified value." ,
910
920
)
@@ -916,11 +926,11 @@ class BooleanParameter(RTPBase):
916
926
type : Literal ["bool" ] = Field (
917
927
default = "bool" , description = "String specifying the type of this parameter"
918
928
)
919
- value : bool = Field (
929
+ value : StrictBool = Field (
920
930
...,
921
931
description = "The value assigned to the parameter; if not supplied by the client, will be assigned the default value." ,
922
932
)
923
- default : bool = Field (
933
+ default : StrictBool = Field (
924
934
...,
925
935
description = "Default value of the parameter, to be used when there is no client-specified value." ,
926
936
)
@@ -929,8 +939,10 @@ class BooleanParameter(RTPBase):
929
939
class EnumChoice (BaseModel ):
930
940
"""Components of choices used in RTP Enum Parameters."""
931
941
932
- displayName : str = Field (..., description = "Display string for the param's choice." )
933
- value : Union [float , str ] = Field (
942
+ displayName : StrictStr = Field (
943
+ ..., description = "Display string for the param's choice."
944
+ )
945
+ value : Union [StrictInt , StrictFloat , StrictStr ] = Field (
934
946
..., description = "Enum value of the param's choice."
935
947
)
936
948
@@ -945,11 +957,11 @@ class EnumParameter(RTPBase):
945
957
choices : List [EnumChoice ] = Field (
946
958
..., description = "List of valid choices for this parameter."
947
959
)
948
- value : Union [float , str ] = Field (
960
+ value : Union [StrictInt , StrictFloat , StrictStr ] = Field (
949
961
...,
950
962
description = "The value assigned to the parameter; if not supplied by the client, will be assigned the default value." ,
951
963
)
952
- default : Union [float , str ] = Field (
964
+ default : Union [StrictInt , StrictFloat , StrictStr ] = Field (
953
965
...,
954
966
description = "Default value of the parameter, to be used when there is no client-specified value." ,
955
967
)
@@ -958,5 +970,5 @@ class EnumParameter(RTPBase):
958
970
RunTimeParameter = Union [NumberParameter , EnumParameter , BooleanParameter ]
959
971
960
972
RunTimeParamValuesType = Dict [
961
- str , Union [float , bool , str ]
973
+ StrictStr , Union [StrictInt , StrictFloat , StrictBool , StrictStr ]
962
974
] # update value types as more RTP types are added
0 commit comments