4040 InputLayout ,
4141 LabelsType ,
4242 OutputLayout ,
43+ PreFillEmpty ,
44+ PreFillType ,
4345 SessionVariablesType ,
4446 TreatAsType ,
4547 WhitelistType ,
46- WidgetsType , PreFillType , PreFillEmpty ,
48+ WidgetsType ,
4749)
50+ from funix .session import get_global_variable , set_global_variable
4851from funix .theme import get_dict_theme , parse_theme
4952from funix .widget import generate_frontend_widget_config
50- from funix .session import set_global_variable , get_global_variable
51-
5253
5354__matplotlib_use = False
5455"""
@@ -551,16 +552,26 @@ def decorator(function: callable) -> callable:
551552 if pre_fill :
552553 for _ , from_arg_function_info in pre_fill .items ():
553554 if isinstance (from_arg_function_info , tuple ):
554- from_arg_function_name = getattr (from_arg_function_info [0 ], "__name__" )
555+ from_arg_function_name = getattr (
556+ from_arg_function_info [0 ], "__name__"
557+ )
555558 from_arg_function_index_or_key = from_arg_function_info [1 ]
556559 if from_arg_function_name in pre_fill_metadata :
557- pre_fill_metadata [from_arg_function_name ].append (from_arg_function_index_or_key )
560+ pre_fill_metadata [from_arg_function_name ].append (
561+ from_arg_function_index_or_key
562+ )
558563 else :
559- pre_fill_metadata [from_arg_function_name ] = [from_arg_function_index_or_key ]
564+ pre_fill_metadata [from_arg_function_name ] = [
565+ from_arg_function_index_or_key
566+ ]
560567 else :
561- from_arg_function_name = getattr (from_arg_function_info , "__name__" )
568+ from_arg_function_name = getattr (
569+ from_arg_function_info , "__name__"
570+ )
562571 if from_arg_function_name in pre_fill_metadata :
563- pre_fill_metadata [from_arg_function_name ].append (PreFillEmpty )
572+ pre_fill_metadata [from_arg_function_name ].append (
573+ PreFillEmpty
574+ )
564575 else :
565576 pre_fill_metadata [from_arg_function_name ] = [PreFillEmpty ]
566577
@@ -904,16 +915,23 @@ def decorated_function_param_getter():
904915 for argument_key , from_function_info in pre_fill .items ():
905916 if isinstance (from_function_info , tuple ):
906917 last_result = get_global_variable (
907- getattr (from_function_info [0 ], "__name__" ) + f"_{ from_function_info [1 ]} "
918+ getattr (from_function_info [0 ], "__name__" )
919+ + f"_{ from_function_info [1 ]} "
908920 )
909921 else :
910922 last_result = get_global_variable (
911923 getattr (from_function_info , "__name__" ) + "_result"
912924 )
913925 if last_result is not None :
914- new_decorated_function ["params" ][argument_key ]["default" ] = last_result
915- new_decorated_function ["schema" ]["properties" ][argument_key ]["default" ] = last_result
916- return Response (dumps (new_decorated_function ), mimetype = "application/json" )
926+ new_decorated_function ["params" ][argument_key ][
927+ "default"
928+ ] = last_result
929+ new_decorated_function ["schema" ]["properties" ][
930+ argument_key
931+ ]["default" ] = last_result
932+ return Response (
933+ dumps (new_decorated_function ), mimetype = "application/json"
934+ )
917935 return Response (dumps (decorated_function ), mimetype = "application/json" )
918936
919937 decorated_function_param_getter .__setattr__ (
@@ -1031,32 +1049,39 @@ def wrapped_function(**wrapped_function_kwargs):
10311049 function_call_result = function (** wrapped_function_kwargs )
10321050 function_call_name = getattr (function , "__name__" )
10331051 if function_call_name in pre_fill_metadata :
1034- for index_or_key in pre_fill_metadata [function_call_name ]:
1052+ for index_or_key in pre_fill_metadata [
1053+ function_call_name
1054+ ]:
10351055 if index_or_key is PreFillEmpty :
1036- set_global_variable (function_call_name + "_result" , function_call_result )
1056+ set_global_variable (
1057+ function_call_name + "_result" ,
1058+ function_call_result ,
1059+ )
10371060 else :
10381061 set_global_variable (
10391062 function_call_name + f"_{ index_or_key } " ,
1040- function_call_result [index_or_key ]
1063+ function_call_result [index_or_key ],
10411064 )
10421065 if return_type_parsed == "Figure" :
10431066 return [get_figure (function_call_result )]
10441067 if return_type_parsed in supported_basic_file_types :
1045- return [
1046- get_static_uri (function_call_result )
1047- ]
1068+ return [get_static_uri (function_call_result )]
10481069 else :
10491070 if isinstance (function_call_result , list ):
10501071 return [function_call_result ]
1051- if not isinstance (function_call_result , (str , dict , tuple )):
1072+ if not isinstance (
1073+ function_call_result , (str , dict , tuple )
1074+ ):
10521075 function_call_result = dumps (function_call_result )
10531076 if cast_to_list_flag :
10541077 function_call_result = list (function_call_result )
10551078 else :
10561079 if isinstance (function_call_result , (str , dict )):
10571080 function_call_result = [function_call_result ]
10581081 if isinstance (function_call_result , tuple ):
1059- function_call_result = list (function_call_result )
1082+ function_call_result = list (
1083+ function_call_result
1084+ )
10601085 if function_call_result and isinstance (
10611086 function_call_result , list
10621087 ):
@@ -1065,7 +1090,9 @@ def wrapped_function(**wrapped_function_kwargs):
10651090 return_type_parsed
10661091 ):
10671092 if single_return_type == "Figure" :
1068- function_call_result [position ] = get_figure (
1093+ function_call_result [
1094+ position
1095+ ] = get_figure (
10691096 function_call_result [position ]
10701097 )
10711098 if (
@@ -1102,12 +1129,16 @@ def wrapped_function(**wrapped_function_kwargs):
11021129 function_call_result = [
11031130 [
11041131 get_static_uri (single )
1105- for single in function_call_result [0 ]
1132+ for single in function_call_result [
1133+ 0
1134+ ]
11061135 ]
11071136 ]
11081137 else :
11091138 function_call_result = [
1110- get_static_uri (function_call_result [0 ])
1139+ get_static_uri (
1140+ function_call_result [0 ]
1141+ )
11111142 ]
11121143 return function_call_result
11131144 return function_call_result
0 commit comments