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

Function fail_callback_output

dash/_validate.py:215–350  ·  view source on GitHub ↗
(output_value, output)

Source from the content-addressed store, hash-verified

213
214
215def fail_callback_output(output_value, output):
216 valid_children = (str, int, float, type(None), Component, NoUpdate)
217 valid_props = (str, int, float, type(None), tuple, MutableSequence, NoUpdate)
218
219 def _raise_invalid(bad_val, outer_val, path, index=None, toplevel=False):
220 bad_type = type(bad_val).__name__
221 outer_id = f"(id={outer_val.id:s})" if getattr(outer_val, "id", False) else ""
222 outer_type = type(outer_val).__name__
223 if toplevel:
224 location = dedent(
225 """
226 The value in question is either the only value returned,
227 or is in the top level of the returned list,
228 """
229 )
230 else:
231 index_string = "[*]" if index is None else f"[{index:d}]"
232 location = dedent(
233 f"""
234 The value in question is located at
235 {index_string} {outer_type} {outer_id}
236 {path},
237 """
238 )
239
240 obj = "tree with one value" if not toplevel else "value"
241 raise exceptions.InvalidCallbackReturnValue(
242 dedent(
243 f"""
244 The callback for `{output!r}`
245 returned a {obj:s} having type `{bad_type}`
246 which is not JSON serializable.
247
248 {location}
249 and has string representation
250 `{bad_val}`
251
252 In general, Dash properties can only be
253 dash components, strings, dictionaries, numbers, None,
254 or lists of those.
255 """
256 )
257 )
258
259 def _valid_child(val):
260 return isinstance(val, valid_children)
261
262 def _valid_prop(val):
263 return isinstance(val, valid_props)
264
265 def _can_serialize(val):
266 if not (_valid_child(val) or _valid_prop(val)):
267 return False
268 try:
269 to_json(val)
270 except TypeError:
271 return False
272 return True

Calls 1

_validate_valueFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…