| 53 | |
| 54 | |
| 55 | class FrozenDict(OrderedDict): |
| 56 | def __init__(self, *args, **kwargs): |
| 57 | super().__init__(*args, **kwargs) |
| 58 | |
| 59 | for key, value in self.items(): |
| 60 | setattr(self, key, value) |
| 61 | |
| 62 | self.__frozen = True |
| 63 | |
| 64 | def __delitem__(self, *args, **kwargs): |
| 65 | raise Exception(f"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.") |
| 66 | |
| 67 | def setdefault(self, *args, **kwargs): |
| 68 | raise Exception(f"You cannot use ``setdefault`` on a {self.__class__.__name__} instance.") |
| 69 | |
| 70 | def pop(self, *args, **kwargs): |
| 71 | raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance.") |
| 72 | |
| 73 | def update(self, *args, **kwargs): |
| 74 | raise Exception(f"You cannot use ``update`` on a {self.__class__.__name__} instance.") |
| 75 | |
| 76 | def __setattr__(self, name, value): |
| 77 | if hasattr(self, "__frozen") and self.__frozen: |
| 78 | raise Exception(f"You cannot use ``__setattr__`` on a {self.__class__.__name__} instance.") |
| 79 | super().__setattr__(name, value) |
| 80 | |
| 81 | def __setitem__(self, name, value): |
| 82 | if hasattr(self, "__frozen") and self.__frozen: |
| 83 | raise Exception(f"You cannot use ``__setattr__`` on a {self.__class__.__name__} instance.") |
| 84 | super().__setitem__(name, value) |
| 85 | |
| 86 | |
| 87 | class ConfigMixin: |
no outgoing calls
no test coverage detected