From: Mike Bayer Date: Tue, 22 Oct 2024 18:03:08 +0000 (-0400) Subject: remove first_init X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db80167902c24f89422018edb0e38e720288b3bc;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git remove first_init The ``first_init`` ORM event has been removed. This event was non-functional throughout the 1.4 and 2.0 series and could not be invoked without raising an internal error, so it is not expected that there is any real-world use of this event hook. Fixes: #10500 Change-Id: I00b522c9d12e412b3be1fc5c6b96e177e6fca666 --- diff --git a/doc/build/changelog/unreleased_21/10500.rst b/doc/build/changelog/unreleased_21/10500.rst new file mode 100644 index 0000000000..6a8c62cc76 --- /dev/null +++ b/doc/build/changelog/unreleased_21/10500.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: change, orm + :tickets: 10500 + + The ``first_init`` ORM event has been removed. This event was + non-functional throughout the 1.4 and 2.0 series and could not be invoked + without raising an internal error, so it is not expected that there is any + real-world use of this event hook. diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index b3f6047d59..534637a48c 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -336,16 +336,6 @@ class InstanceEvents(event.Events[ClassManager[Any]]): super()._clear() _InstanceEventsHold._clear() - def first_init(self, manager: ClassManager[_O], cls: Type[_O]) -> None: - """Called when the first instance of a particular mapping is called. - - This event is called when the ``__init__`` method of a class - is called the first time for that particular class. The event - invokes before ``__init__`` actually proceeds as well as before - the :meth:`.InstanceEvents.init` event is invoked. - - """ - def init(self, target: _O, args: Any, kwargs: Any) -> None: """Receive an instance when its constructor is called. diff --git a/lib/sqlalchemy/orm/instrumentation.py b/lib/sqlalchemy/orm/instrumentation.py index 1452596beb..8104e3cabd 100644 --- a/lib/sqlalchemy/orm/instrumentation.py +++ b/lib/sqlalchemy/orm/instrumentation.py @@ -345,7 +345,6 @@ class ClassManager( @util.memoized_property def _state_constructor(self) -> Type[state.InstanceState[_O]]: - self.dispatch.first_init(self, self.class_) return state.InstanceState def manage(self):