MCPcopy Create free account
hub / github.com/AlayaLab/Hive / FrozenDict

Class FrozenDict

models/flowsep/diffusers/configuration_utils.py:50–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49
50class FrozenDict(OrderedDict):
51 def __init__(self, *args, **kwargs):
52 super().__init__(*args, **kwargs)
53
54 for key, value in self.items():
55 setattr(self, key, value)
56
57 self.__frozen = True
58
59 def __delitem__(self, *args, **kwargs):
60 raise Exception(f"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.")
61
62 def setdefault(self, *args, **kwargs):
63 raise Exception(f"You cannot use ``setdefault`` on a {self.__class__.__name__} instance.")
64
65 def pop(self, *args, **kwargs):
66 raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance.")
67
68 def update(self, *args, **kwargs):
69 raise Exception(f"You cannot use ``update`` on a {self.__class__.__name__} instance.")
70
71 def __setattr__(self, name, value):
72 if hasattr(self, "__frozen") and self.__frozen:
73 raise Exception(f"You cannot use ``__setattr__`` on a {self.__class__.__name__} instance.")
74 super().__setattr__(name, value)
75
76 def __setitem__(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().__setitem__(name, value)
80
81
82class ConfigMixin:

Callers 15

register_to_configMethod · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected