From: Carlos Sousa Date: Mon, 25 Sep 2023 15:20:39 +0000 (-0300) Subject: Update AsyncSession, replace get call by get_one, remove casting and null check X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22e1dda8989e57d3fcbc4cac79d59065dbc6e4a9;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Update AsyncSession, replace get call by get_one, remove casting and null check --- diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 14e5a484e6..5072e1f850 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -625,14 +625,14 @@ class AsyncSession(ReversibleProxy[Session]): execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, ) -> _O: """Return an instance based on the given primary key identifier, - or raise an exception. + or raise an exception. - Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects - no rows. + Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects + no rows. """ result_obj = await greenlet_spawn( - cast("Callable[..., _O]", self.sync_session.get), + self.sync_session.get_one, entity, ident, options=options, @@ -640,12 +640,6 @@ class AsyncSession(ReversibleProxy[Session]): with_for_update=with_for_update, identity_token=identity_token, ) - - if result_obj is None: - raise async_exc.NoResultFound( - "No row was found when one was required" - ) - return result_obj @overload