MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / add_item

Method add_item

lib/sqlalchemy/orm/clsregistry.py:240–256  ·  view source on GitHub ↗
(self, item: Type[Any])

Source from the content-addressed store, hash-verified

238 self.on_remove()
239
240 def add_item(self, item: Type[Any]) -> None:
241 # protect against class registration race condition against
242 # asynchronous garbage collection calling _remove_item,
243 # [ticket:3208] and [ticket:10782]
244 modules = {
245 cls.__module__
246 for cls in [ref() for ref in list(self.contents)]
247 if cls is not None
248 }
249 if item.__module__ in modules:
250 util.warn(
251 "This declarative base already contains a class with the "
252 "same class name and module name as %s.%s, and will "
253 "be replaced in the string-lookup table."
254 % (item.__module__, item.__name__)
255 )
256 self.contents.add(weakref.ref(item, self._remove_item))
257
258
259class _ModuleMarker(_ClsRegistryToken):

Callers 1

add_classMethod · 0.80

Calls 2

warnMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected