MCPcopy Create free account
hub / github.com/StackStorm/st2 / __getitem__

Method __getitem__

st2common/st2common/fields.py:290–304  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

288 return default
289
290 def __getitem__(self, key):
291 value = super().__getitem__(key)
292
293 if isinstance(value, dict) and not isinstance(value, BaseDict):
294 value = BaseDict(value, None, f"{self._name}.{key}")
295 super().__setitem__(key, value)
296 value._instance = self._instance
297 # We also need to return a wrapper class in case of a list to ensure updates o the
298 # list items are correctly racked
299 elif isinstance(value, list) and not isinstance(value, BaseList):
300 value = BaseList(value, None, f"{self._name}.{key}")
301 super().__setitem__(key, value)
302 value._instance = self._instance
303
304 return value
305
306 def __getstate__(self):
307 self.instance = None

Callers 1

getMethod · 0.95

Calls 4

BaseDictClass · 0.85
BaseListClass · 0.85
__getitem__Method · 0.45
__setitem__Method · 0.45

Tested by

no test coverage detected