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

Function _del_attribute

lib/sqlalchemy/orm/decl_base.py:2156–2177  ·  view source on GitHub ↗
(cls: Type[Any], key: str)

Source from the content-addressed store, hash-verified

2154
2155
2156def _del_attribute(cls: Type[Any], key: str) -> None:
2157 if (
2158 "__mapper__" in cls.__dict__
2159 and key in cls.__dict__
2160 and not cast(
2161 "MappedClassProtocol[Any]", cls
2162 ).__mapper__._dispose_called
2163 ):
2164 value = cls.__dict__[key]
2165 if isinstance(
2166 value, (Column, _MapsColumns, MapperProperty, QueryableAttribute)
2167 ):
2168 raise NotImplementedError(
2169 "Can't un-map individual mapped attributes on a mapped class."
2170 )
2171 else:
2172 type.__delattr__(cls, key)
2173 cast(
2174 "MappedClassProtocol[Any]", cls
2175 ).__mapper__._expire_memoizations()
2176 else:
2177 type.__delattr__(cls, key)
2178
2179
2180def _declarative_constructor(self: Any, **kwargs: Any) -> None:

Callers 1

__delattr__Method · 0.85

Calls 3

castFunction · 0.85
_expire_memoizationsMethod · 0.80
__delattr__Method · 0.45

Tested by

no test coverage detected