Skip to content

Commit 6f1cc2d

Browse files
committed
refactor: update TransactionContext to use concrete type for __aenter__ method
1 parent 9f42589 commit 6f1cc2d

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

tortoise/backends/base/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
306306
self._lock.release()
307307

308308

309-
class TransactionContext(Generic[T_conn]):
309+
class TransactionContext:
310310
"""A context manager interface for transactions. It is returned from in_transaction
311311
and _in_transaction."""
312312

313313
client: TransactionalDBClient
314314

315315
@abc.abstractmethod
316-
async def __aenter__(self) -> T_conn: ...
316+
async def __aenter__(self) -> TransactionalDBClient: ...
317317

318318
@abc.abstractmethod
319319
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...

tortoise/backends/sqlite/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
Capabilities,
1717
ConnectionWrapper,
1818
NestedTransactionContext,
19-
T_conn,
2019
TransactionalDBClient,
2120
TransactionContext,
2221
)
@@ -191,7 +190,7 @@ async def ensure_connection(self) -> None:
191190
await self.connection._parent.create_connection(with_db=True)
192191
self.connection._connection = self.connection._parent._connection
193192

194-
async def __aenter__(self) -> T_conn:
193+
async def __aenter__(self) -> TransactionalDBClient:
195194
await self._trxlock.acquire()
196195
await self.ensure_connection()
197196
self.token = get_connections().set(self.connection_name, self.connection)

0 commit comments

Comments
 (0)