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

Function _generative

lib/sqlalchemy/sql/base.py:269–290  ·  view source on GitHub ↗

non-caching _generative() decorator. This is basically the legacy decorator that copies the object and runs a method on the new copy.

(fn: _Fn)

Source from the content-addressed store, hash-verified

267
268
269def _generative(fn: _Fn) -> _Fn:
270 """non-caching _generative() decorator.
271
272 This is basically the legacy decorator that copies the object and
273 runs a method on the new copy.
274
275 """
276
277 @util.decorator
278 def _generative(
279 fn: _Fn, self: _SelfGenerativeType, *args: Any, **kw: Any
280 ) -> _SelfGenerativeType:
281 """Mark a method as generative."""
282
283 self = self._generate()
284 x = fn(self, *args, **kw)
285 assert x is self, "generative methods must return self"
286 return self
287
288 decorated = _generative(fn)
289 decorated.non_generative = fn # type: ignore
290 return decorated
291
292
293def _exclusive_against(*names: str, **kw: Any) -> Callable[[_Fn], _Fn]:

Callers

nothing calls this directly

Calls 1

_generateMethod · 0.45

Tested by

no test coverage detected