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

Method __setattr__

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

Source from the content-addressed store, hash-verified

978 self.__convert_and_store(key, value)
979
980 def __setattr__(self, key, value):
981 if key == "_box_config":
982 return object.__setattr__(self, key, value)
983 if key in self._box_internal_attrs:
984 return object.__setattr__(self, key, value)
985 if self._box_config["frozen_box"] and self._box_config["__created"]:
986 raise BoxError("Box is frozen")
987 if key in self._protected_keys:
988 raise BoxKeyError(f'Key name "{key}" is protected')
989
990 safe_key = self._safe_attr(key)
991 if safe_key in self._box_config["__safe_keys"]:
992 key = self._box_config["__safe_keys"][safe_key]
993
994 # if user has customized property setter, fall back to default implementation
995 if _get_property_func(self, key)[1] is not None:
996 super().__setattr__(key, value)
997 else:
998 self.__setitem__(key, value)
999
1000 def __delitem__(self, key):
1001 if self._box_config["frozen_box"]:

Callers 3

test_boxMethod · 0.95
__copy_internalsMethod · 0.80

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