MCPcopy
hub / github.com/plotly/dash / Patch

Class Patch

dash/_patch.py:18–175  ·  view source on GitHub ↗

Patch a callback output value Act like a proxy of the output prop value on the frontend. Supported prop types: Dictionaries and lists.

Source from the content-addressed store, hash-verified

16
17
18class Patch:
19 """
20 Patch a callback output value
21
22 Act like a proxy of the output prop value on the frontend.
23
24 Supported prop types: Dictionaries and lists.
25 """
26
27 def __init__(
28 self,
29 location: Optional[List[_KeyType]] = None,
30 parent: Optional["Patch"] = None,
31 ):
32 if location is not None:
33 self._location: List[_KeyType] = location
34 else:
35 # pylint: disable=consider-using-ternary
36 self._location = (parent and parent._location) or []
37 if parent is not None:
38 self._operations: List[Dict[str, Any]] = parent._operations
39 else:
40 self._operations = []
41
42 def __getstate__(self):
43 return vars(self)
44
45 def __setstate__(self, state):
46 vars(self).update(state)
47
48 def __getitem__(self, item: _KeyType) -> "Patch":
49 validate_slice(item)
50 return Patch(location=self._location + [item], parent=self)
51
52 def __getattr__(self, item: _KeyType) -> "Patch":
53 if item == "tolist":
54 # to_json fix
55 raise AttributeError
56 if item == "_location":
57 return self._location # type: ignore
58 if item == "_operations":
59 return self._operations # type: ignore
60 return self.__getitem__(item)
61
62 def __setattr__(self, key: _KeyType, value: Any):
63 if key in ("_location", "_operations"):
64 self.__dict__[str(key)] = value
65 else:
66 self.__setitem__(key, value)
67
68 def __delattr__(self, item: _KeyType):
69 self.__delitem__(item)
70
71 def __setitem__(self, key: _KeyType, value: Any):
72 validate_slice(key)
73 if value is _noop:
74 # The += set themselves.
75 return

Callers 15

patch_colorFunction · 0.90
patch_titleFunction · 0.90
on_valueFunction · 0.90
on_clickFunction · 0.90
on_insertFunction · 0.90
on_clearFunction · 0.90
on_reverseFunction · 0.90
on_removeFunction · 0.90
on_addFunction · 0.90
on_mulFunction · 0.90
on_divFunction · 0.90
on_mergeFunction · 0.90

Calls

no outgoing calls

Tested by 15

patch_colorFunction · 0.72
patch_titleFunction · 0.72
on_valueFunction · 0.72
on_clickFunction · 0.72
on_insertFunction · 0.72
on_clearFunction · 0.72
on_reverseFunction · 0.72
on_removeFunction · 0.72
on_addFunction · 0.72
on_mulFunction · 0.72
on_divFunction · 0.72
on_mergeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…