From: Mike Bayer Date: Mon, 8 Jan 2024 14:15:17 +0000 (-0500) Subject: DBAPIConnection can be None for checkin event X-Git-Tag: rel_2_0_26~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80f772a6c0d75dc316b4141d83f502f64a9852bd;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git DBAPIConnection can be None for checkin event Fixed the type signature for the :meth:`.PoolEvents.checkin` event to indicate that the given :class:`.DBAPIConnection` argument may be ``None`` in the case where the connection has been invalidated. Change-Id: I4c6f0cf999f2ffb730909e2688eb3b0794ecf2ab (cherry picked from commit 071d3e2d2b11a96fc5a143530357244177259189) --- diff --git a/doc/build/changelog/unreleased_20/checkin_conn_none.rst b/doc/build/changelog/unreleased_20/checkin_conn_none.rst new file mode 100644 index 0000000000..9aeed4784f --- /dev/null +++ b/doc/build/changelog/unreleased_20/checkin_conn_none.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: bug, typing + + Fixed the type signature for the :meth:`.PoolEvents.checkin` event to + indicate that the given :class:`.DBAPIConnection` argument may be ``None`` + in the case where the connection has been invalidated. diff --git a/lib/sqlalchemy/pool/events.py b/lib/sqlalchemy/pool/events.py index 99d180abc9..4b4f4e4785 100644 --- a/lib/sqlalchemy/pool/events.py +++ b/lib/sqlalchemy/pool/events.py @@ -173,7 +173,7 @@ class PoolEvents(event.Events[Pool]): def checkin( self, - dbapi_connection: DBAPIConnection, + dbapi_connection: Optional[DBAPIConnection], connection_record: ConnectionPoolEntry, ) -> None: """Called when a connection returns to the pool.