11from contextlib import contextmanager , asynccontextmanager
22from typing import Iterable , Type , Iterator , AsyncIterator
33
4+ from sqlalchemy .ext .asyncio import AsyncSession
5+ from sqlalchemy .orm import Session
6+
47from sqlalchemy_bind_manager import SQLAlchemyRepository , SQLAlchemyAsyncRepository
58from sqlalchemy_bind_manager ._bind_manager import SQLAlchemyBind , SQLAlchemyAsyncBind
69from sqlalchemy_bind_manager ._transaction_handler import (
@@ -21,9 +24,9 @@ def __init__(
2124 setattr (self , r .__name__ , r (session = self ._transaction_handler .session ))
2225
2326 @contextmanager
24- def transaction (self , read_only : bool = False ) -> Iterator [None ]:
25- with self ._transaction_handler .get_session (read_only = read_only ) as s :
26- yield s
27+ def transaction (self , read_only : bool = False ) -> Iterator [Session ]:
28+ with self ._transaction_handler .get_session (read_only = read_only ) as _s :
29+ yield _s
2730
2831
2932class AsyncUnitOfWork :
@@ -40,6 +43,6 @@ def __init__(
4043 setattr (self , r .__name__ , r (session = self ._transaction_handler .session ))
4144
4245 @asynccontextmanager
43- async def transaction (self , read_only : bool = False ) -> AsyncIterator [None ]:
44- async with self ._transaction_handler .get_session (read_only = read_only ):
45- yield None
46+ async def transaction (self , read_only : bool = False ) -> AsyncIterator [AsyncSession ]:
47+ async with self ._transaction_handler .get_session (read_only = read_only ) as _s :
48+ yield _s
0 commit comments