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

Method new_instance

lib/sqlalchemy/orm/instrumentation.py:501–510  ·  view source on GitHub ↗
(self, state: Optional[InstanceState[_O]] = None)

Source from the content-addressed store, hash-verified

499 # InstanceState management
500
501 def new_instance(self, state: Optional[InstanceState[_O]] = None) -> _O:
502 # here, we would prefer _O to be bound to "object"
503 # so that mypy sees that __new__ is present. currently
504 # it's bound to Any as there were other problems not having
505 # it that way but these can be revisited
506 instance = self.class_.__new__(self.class_)
507 if state is None:
508 state = self._state_constructor(instance, self)
509 self._state_setter(instance, state)
510 return instance
511
512 def setup_instance(
513 self, instance: _O, state: Optional[InstanceState[_O]] = None

Callers 2

_instanceFunction · 0.45
_mergeMethod · 0.45

Calls 2

_state_constructorMethod · 0.95
__new__Method · 0.45

Tested by

no test coverage detected