MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected