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

Function _remove_class

lib/sqlalchemy/orm/clsregistry.py:119–149  ·  view source on GitHub ↗
(
    classname: str, cls: Type[Any], decl_class_registry: _ClsRegistryType
)

Source from the content-addressed store, hash-verified

117
118
119def _remove_class(
120 classname: str, cls: Type[Any], decl_class_registry: _ClsRegistryType
121) -> None:
122 if classname in decl_class_registry:
123 existing = decl_class_registry[classname]
124 if isinstance(existing, _MultipleClassMarker):
125 existing.remove_item(cls)
126 else:
127 del decl_class_registry[classname]
128
129 try:
130 root_module = cast(
131 _ModuleMarker, decl_class_registry["_sa_module_registry"]
132 )
133 except KeyError:
134 return
135
136 tokens = cls.__module__.split(".")
137
138 while tokens:
139 token = tokens.pop(0)
140 module = root_module.get_module(token)
141 for token in tokens:
142 module = module.get_module(token)
143 try:
144 module.remove_class(classname, cls)
145 except AttributeError:
146 if not isinstance(module, _ModuleMarker):
147 pass
148 else:
149 raise
150
151
152def _key_is_empty(

Callers

nothing calls this directly

Calls 6

remove_itemMethod · 0.80
splitMethod · 0.80
get_moduleMethod · 0.80
remove_classMethod · 0.80
castFunction · 0.50
popMethod · 0.45

Tested by

no test coverage detected