@@ -3905,6 +3905,24 @@ def __init__(self, title: str, config: dict = None):
3905
3905
f"config may only contain keys: { default_config .keys ()} "
3906
3906
)
3907
3907
3908
+ for k in ["bar" , "red" , "green" , "blue" ]:
3909
+ if k in config :
3910
+ if not all (isinstance (v , (int , float )) for v in config [k ]):
3911
+ raise ValueError (f"values for { k } component must all be numeric" )
3912
+ required_keys = {"value_start" , "value_range" , "period" , "offset" }
3913
+ if not required_keys .issubset (set (config .keys ())):
3914
+ raise ValueError (f"{ k } must contain all of { required_keys } " )
3915
+
3916
+ if "phrases" in config :
3917
+ if type (config ["phrases" ]) is not list :
3918
+ raise ValueError ("phrases must be a list" )
3919
+ if not all (isinstance (v , str ) for v in config ["phrases" ]):
3920
+ raise ValueError ("phrases must be a list of strings" )
3921
+
3922
+ if "phrase_delay" in config :
3923
+ if not all (isinstance (v , (int , float )) for v in config ["phrase_delay" ]):
3924
+ raise ValueError ("phrase_delay must be numeric" )
3925
+
3908
3926
self .config = {** default_config , ** config }
3909
3927
3910
3928
self .title = title
@@ -3930,6 +3948,9 @@ def run(self, fn: callable, *args, **kwargs):
3930
3948
Runs the function in a separate co-routine, while animating the progress bar in
3931
3949
another.
3932
3950
"""
3951
+ if not callable (fn ):
3952
+ raise ValueError ("fn must be a callable" )
3953
+
3933
3954
return asyncio .run (self ._dispatch (fn , * args , ** kwargs ))
3934
3955
3935
3956
def close (self ):
0 commit comments