MCPcopy Create free account
hub / github.com/cdgriffith/Box / __setattr__

Method __setattr__

box/box.py:991–1009  ·  view source on GitHub ↗
(self, key, value)

Source from the content-addressed store, hash-verified

989 self.__convert_and_store(key, value)
990
991 def __setattr__(self, key, value):
992 if key == "_box_config":
993 return object.__setattr__(self, key, value)
994 if key in self._box_internal_attrs:
995 return object.__setattr__(self, key, value)
996 if self._box_config["frozen_box"] and self._box_config["__created"]:
997 raise BoxError("Box is frozen")
998 if key in self._protected_keys:
999 raise BoxKeyError(f'Key name "{key}" is protected')
1000
1001 safe_key = self._safe_attr(key)
1002 if safe_key in self._box_config["__safe_keys"]:
1003 key = self._box_config["__safe_keys"][safe_key]
1004
1005 # if user has customized property setter, fall back to default implementation
1006 if _get_property_func(self, key)[1] is not None:
1007 super().__setattr__(key, value)
1008 else:
1009 self.__setitem__(key, value)
1010
1011 def __delitem__(self, key):
1012 if self._box_config["frozen_box"]:

Callers 3

test_boxMethod · 0.95
__copy_internalsMethod · 0.45

Calls 5

_safe_attrMethod · 0.95
__setitem__Method · 0.95
BoxErrorClass · 0.90
BoxKeyErrorClass · 0.90
_get_property_funcFunction · 0.85

Tested by 2

test_boxMethod · 0.76