MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/orm/instrumentation.py:147–190  ·  view source on GitHub ↗
(self, class_)

Source from the content-addressed store, hash-verified

145 self.expired_attribute_loader = obj
146
147 def __init__(self, class_):
148 self.class_ = class_
149 self.info = {}
150 self.new_init = None
151 self.local_attrs = {}
152 self.originals = {}
153 self._finalized = False
154 self.factory = None
155 self.init_method = None
156
157 self._bases = [
158 mgr
159 for mgr in cast(
160 "List[Optional[ClassManager[Any]]]",
161 [
162 opt_manager_of_class(base)
163 for base in self.class_.__bases__
164 if isinstance(base, type)
165 ],
166 )
167 if mgr is not None
168 ]
169
170 for base_ in self._bases:
171 self.update(base_)
172
173 cast(
174 "InstanceEvents", self.dispatch._events
175 )._new_classmanager_instance(class_, self)
176
177 for basecls in class_.__mro__:
178 mgr = opt_manager_of_class(basecls)
179 if mgr is not None:
180 self.dispatch._update(mgr.dispatch)
181
182 self.manage()
183
184 if "__del__" in class_.__dict__:
185 util.warn(
186 "__del__() method on class %s will "
187 "cause unreachable cycles and memory leaks, "
188 "as SQLAlchemy instrumentation often creates "
189 "reference cycles. Please remove this method." % class_
190 )
191
192 def _update_state(
193 self,

Callers

nothing calls this directly

Calls 7

manageMethod · 0.95
castFunction · 0.85
opt_manager_of_classFunction · 0.85
updateMethod · 0.45
_updateMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected