MCPcopy Create free account
hub / github.com/ipython/traitlets / LazyConfigValue

Class LazyConfigValue

traitlets/config/loader.py:85–216  ·  view source on GitHub ↗

Proxy object for exposing methods on configurable containers These methods allow appending/extending/updating to add to non-empty defaults instead of clobbering them. Exposes: - append, extend, insert on lists - update on dicts - update, add on sets

Source from the content-addressed store, hash-verified

83
84
85class LazyConfigValue(HasTraits):
86 """Proxy object for exposing methods on configurable containers
87
88 These methods allow appending/extending/updating
89 to add to non-empty defaults instead of clobbering them.
90
91 Exposes:
92
93 - append, extend, insert on lists
94 - update on dicts
95 - update, add on sets
96 """
97
98 _value = None
99
100 # list methods
101 _extend: List[t.Any] = List()
102 _prepend: List[t.Any] = List()
103 _inserts: List[t.Any] = List()
104
105 def append(self, obj: t.Any) -> None:
106 """Append an item to a List"""
107 self._extend.append(obj)
108
109 def extend(self, other: t.Any) -> None:
110 """Extend a list"""
111 self._extend.extend(other)
112
113 def prepend(self, other: t.Any) -> None:
114 """like list.extend, but for the front"""
115 self._prepend[:0] = other
116
117 def merge_into(self, other: t.Any) -> t.Any:
118 """
119 Merge with another earlier LazyConfigValue or an earlier container.
120 This is useful when having global system-wide configuration files.
121
122 Self is expected to have higher precedence.
123
124 Parameters
125 ----------
126 other : LazyConfigValue or container
127
128 Returns
129 -------
130 LazyConfigValue
131 if ``other`` is also lazy, a reified container otherwise.
132 """
133 if isinstance(other, LazyConfigValue):
134 other._extend.extend(self._extend)
135 self._extend = other._extend
136
137 self._prepend.extend(other._prepend)
138
139 other._inserts.extend(self._inserts)
140 self._inserts = other._inserts
141
142 if self._update:

Callers 1

__getitem__Method · 0.85

Calls 2

ListClass · 0.90
AnyClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…