MCPcopy Index your code
hub / github.com/plotly/dash / handle_callback_args

Function handle_callback_args

dash/dependencies.py:381–409  ·  view source on GitHub ↗

Split args into outputs, inputs and states

(args, kwargs)

Source from the content-addressed store, hash-verified

379
380
381def handle_callback_args(args, kwargs):
382 """Split args into outputs, inputs and states"""
383 prevent_initial_call = kwargs.get("prevent_initial_call", None)
384 if prevent_initial_call is None and args and isinstance(args[-1], bool):
385 args, prevent_initial_call = args[:-1], args[-1]
386
387 # flatten args, to support the older syntax where outputs, inputs, and states
388 # each needed to be in their own list
389 flat_args = []
390 for arg in args:
391 flat_args += arg if isinstance(arg, (list, tuple)) else [arg]
392
393 outputs = extract_callback_args(flat_args, kwargs, "output", Output)
394 validate_outputs = outputs
395 if len(outputs) == 1:
396 out0 = kwargs.get("output", args[0] if args else None)
397 if not isinstance(out0, (list, tuple)):
398 # unless it was explicitly provided as a list, a single output
399 # should be unwrapped. That ensures the return value of the
400 # callback is also not expected to be wrapped in a list.
401 outputs = outputs[0]
402
403 inputs = extract_callback_args(flat_args, kwargs, "inputs", Input)
404 states = extract_callback_args(flat_args, kwargs, "state", State)
405
406 types = Input, Output, State
407 validate_callback(validate_outputs, inputs, states, flat_args, types)
408
409 return outputs, inputs, states, prevent_initial_call

Callers 1

Calls 3

extract_callback_argsFunction · 0.85
validate_callbackFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…