@@ -100,6 +100,7 @@ class _NoUpdate(object):
100
100
ns["{function_name}"] = {clientside_function};
101
101
"""
102
102
103
+
103
104
def extract_callback_args (args , kwargs , name , type_ ):
104
105
"""Extract arguments for callback from a name and type"""
105
106
print (args , kwargs )
@@ -109,9 +110,10 @@ def extract_callback_args(args, kwargs, name, type_):
109
110
parameters .append (args .pop (0 ))
110
111
return parameters
111
112
113
+
112
114
def _handle_callback_args (* args , ** kwargs ):
113
115
"""Split args into outputs, inputs and states"""
114
- prevent_initial_call = kwargs .get (' prevent_initial_call' , None )
116
+ prevent_initial_call = kwargs .get (" prevent_initial_call" , None )
115
117
# flatten args
116
118
args = [
117
119
arg
@@ -122,13 +124,14 @@ def _handle_callback_args(*args, **kwargs):
122
124
arg_or_list if isinstance (arg_or_list , (list , tuple )) else [arg_or_list ]
123
125
)
124
126
]
125
- outputs = extract_callback_args (args , kwargs , ' output' , Output )
126
- inputs = extract_callback_args (args , kwargs , ' inputs' , Input )
127
- states = extract_callback_args (args , kwargs , ' state' , State )
127
+ outputs = extract_callback_args (args , kwargs , " output" , Output )
128
+ inputs = extract_callback_args (args , kwargs , " inputs" , Input )
129
+ states = extract_callback_args (args , kwargs , " state" , State )
128
130
129
131
if args :
130
132
raise TypeError (
131
- "callback must received first all Outputs, then all Inputs, then all States" )
133
+ "callback must received first all Outputs, then all Inputs, then all States"
134
+ )
132
135
return [
133
136
outputs ,
134
137
inputs ,
@@ -860,9 +863,7 @@ def interpolate_index(self, **kwargs):
860
863
def dependencies (self ):
861
864
return flask .jsonify (self ._callback_list )
862
865
863
- def _insert_callback (
864
- self , output , inputs , state , prevent_initial_call
865
- ):
866
+ def _insert_callback (self , output , inputs , state , prevent_initial_call ):
866
867
if prevent_initial_call is None :
867
868
prevent_initial_call = self .config .prevent_initial_callbacks
868
869
@@ -998,22 +999,15 @@ def callback(self, *args, **kwargs):
998
999
not to fire when its outputs are first added to the page. Defaults to
999
1000
`False` unless `prevent_initial_callbacks=True` at the app level.
1000
1001
"""
1001
- kwargs ['prevent_initial_call' ] = kwargs .get (
1002
- 'prevent_initial_call' , None )
1003
- output = kwargs .get ('output' , args [0 ])
1002
+ kwargs ["prevent_initial_call" ] = kwargs .get ("prevent_initial_call" , None )
1003
+ output = kwargs .get ("output" , args [0 ])
1004
1004
# for backward compatibility, store whether first argument is a
1005
1005
# list of only 1 Output
1006
- specified_output_list = (
1007
- isinstance (output , (list , tuple )) and len (output ) == 1 )
1008
- (
1009
- output ,
1010
- inputs ,
1011
- state ,
1012
- prevent_initial_call ,
1013
- ) = _handle_callback_args (* args , ** kwargs )
1014
- callback_id = self ._insert_callback (
1015
- output , inputs , state , prevent_initial_call
1006
+ specified_output_list = isinstance (output , (list , tuple )) and len (output ) == 1
1007
+ (output , inputs , state , prevent_initial_call ,) = _handle_callback_args (
1008
+ * args , ** kwargs
1016
1009
)
1010
+ callback_id = self ._insert_callback (output , inputs , state , prevent_initial_call )
1017
1011
1018
1012
def wrap_func (func ):
1019
1013
@wraps (func )
0 commit comments