MCPcopy Index your code
hub / github.com/plotly/plotly.py / validate_coerce

Method validate_coerce

_plotly_utils/basevalidators.py:2543–2572  ·  view source on GitHub ↗
(self, v, skip_invalid=False)

Source from the content-addressed store, hash-verified

2541 return self._data_class
2542
2543 def validate_coerce(self, v, skip_invalid=False):
2544 if v is None:
2545 v = []
2546
2547 elif isinstance(v, (list, tuple)):
2548 res = []
2549 invalid_els = []
2550 for v_el in v:
2551 if isinstance(v_el, self.data_class):
2552 res.append(self.data_class(v_el))
2553 elif isinstance(v_el, dict):
2554 res.append(self.data_class(v_el, skip_invalid=skip_invalid))
2555 else:
2556 if skip_invalid:
2557 res.append(self.data_class())
2558 else:
2559 res.append(None)
2560 invalid_els.append(v_el)
2561
2562 if invalid_els:
2563 self.raise_invalid_elements(invalid_els)
2564
2565 v = to_scalar_or_list(res)
2566 else:
2567 if skip_invalid:
2568 v = []
2569 else:
2570 self.raise_invalid_val(v)
2571
2572 return v
2573
2574 def present(self, v):
2575 # Return compound object as tuple

Callers

nothing calls this directly

Calls 4

data_classMethod · 0.95
to_scalar_or_listFunction · 0.85
raise_invalid_valMethod · 0.80

Tested by

no test coverage detected