MCPcopy
hub / github.com/huggingface/diffusers / FrozenDict

Class FrozenDict

src/diffusers/configuration_utils.py:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…