@@ -49,14 +49,18 @@ class EmptyUpdateError(ValidationError):
4949
5050
5151class BaseService [TResponse ](BaseModel , ABC ):
52+ """Base interface for async application services."""
53+
5254 context : dict [str , Any ] | None = None
5355
5456 @abstractmethod
5557 async def __call__ (self , * args , ** kwargs ) -> TResponse :
56- pass
58+ """Execute service logic."""
5759
5860
5961class BaseSessionService [TResponse ](BaseService [TResponse ], ABC ):
62+ """Base service with managed database session."""
63+
6064 def __init__ (self , / , ** data : Any ) -> None :
6165 super ().__init__ (** data )
6266
@@ -70,7 +74,12 @@ def session(self) -> AsyncSession:
7074 return self ._session
7175
7276 @abstractmethod
73- async def process (self , * args , ** kwargs ) -> TResponse : ...
77+ async def process (self , * args , ** kwargs ) -> TResponse :
78+ """
79+ Execute the main logic of the service.
80+
81+ A database session is available via ``self.session``.
82+ """
7483
7584 async def __call__ (self , * args , ** kwargs ) -> TResponse :
7685 async with session_manager .session () as session :
@@ -80,6 +89,8 @@ async def __call__(self, *args, **kwargs) -> TResponse:
8089
8190
8291class BaseUserAuthenticatedService [TResponse ](BaseSessionService [TResponse ], ABC ):
92+ """Base service with an authenticated user available via ``self.user``."""
93+
8394 token : str
8495
8596 def __init__ (self , / , ** data : Any ) -> None :
0 commit comments