MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _generative

Function _generative

lib/sqlalchemy/sql/base.py:281–302  ·  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

279
280
281def _generative(fn: _Fn) -> _Fn:
282 """non-caching _generative() decorator.
283
284 This is basically the legacy decorator that copies the object and
285 runs a method on the new copy.
286
287 """
288
289 @util.decorator
290 def _generative(
291 fn: _Fn, self: _SelfGenerativeType, *args: Any, **kw: Any
292 ) -> _SelfGenerativeType:
293 """Mark a method as generative."""
294
295 self = self._generate()
296 x = fn(self, *args, **kw)
297 assert x is self, "generative methods must return self"
298 return self
299
300 decorated = _generative(fn)
301 decorated.non_generative = fn # type: ignore
302 return decorated
303
304
305def _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