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

Class Bunch

traitlets/utils/bunch.py:13–29  ·  view source on GitHub ↗

A dict with attribute-access

Source from the content-addressed store, hash-verified

11
12
13class Bunch(dict): # type:ignore[type-arg]
14 """A dict with attribute-access"""
15
16 def __getattr__(self, key: str) -> Any:
17 try:
18 return self.__getitem__(key)
19 except KeyError as e:
20 raise AttributeError(key) from e
21
22 def __setattr__(self, key: str, value: Any) -> None:
23 self.__setitem__(key, value)
24
25 def __dir__(self) -> list[str]:
26 names: list[str] = []
27 names.extend(super().__dir__())
28 names.extend(self.keys())
29 return names

Callers 8

test_bunchFunction · 0.90
test_bunch_dirFunction · 0.90
getMethod · 0.85
_cross_validateMethod · 0.85
compatible_observerFunction · 0.85
__init__Method · 0.85
_notify_traitMethod · 0.85
_notify_observersMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_bunchFunction · 0.72
test_bunch_dirFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…