From 98846f5c56ca3eba4b952fe2ad20313c3192d1e2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 13 Apr 2021 04:30:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Improve=20and=20rename=20SQLAlch?= =?UTF-8?q?emyPDA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalnet/engineer/pda.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/royalnet/engineer/pda.py b/royalnet/engineer/pda.py index c648d950..bcdd3084 100644 --- a/royalnet/engineer/pda.py +++ b/royalnet/engineer/pda.py @@ -254,10 +254,10 @@ class ConversationListPDA(PDA, metaclass=abc.ABCMeta): return full -class WithDatabaseSession(ConversationListPDA, metaclass=abc.ABCMeta): +class SQLAlchemyPDA(ConversationListPDA, metaclass=abc.ABCMeta): """ - A :class:`.ConversationListPDA` with database support provided by :mod:`sqlalchemy`\\ by extending - :meth:`._conversation_kwargs` with the ``_session`` kwarg. + Extends :class:`.ConversationListPDA` with database support provided by :mod:`sqlalchemy`\\ by adding the + ``_session`` kwarg to the :meth:`._conversation_kwargs`. """ def __init__(self, engine: sqlalchemy.engine.Engine, conversation_kwargs: dict[str, t.Any]): @@ -271,15 +271,14 @@ class WithDatabaseSession(ConversationListPDA, metaclass=abc.ABCMeta): with self.Session(future=True) as session: yield { - "_pda": self, - "_conv": conv, "_session": session, - **self.conversation_kwargs, + **super()._conversation_kwargs(conv=conv), } __all__ = ( "PDA", "ConversationListPDA", - "WithDatabaseSession", + "SQLAlchemyPDA", + )