Skip to content

Commit 85269e2

Browse files
fix: use contextlib.suppress for ROLLBACK error in transaction()
Replaces try/except/pass with contextlib.suppress(Exception), matching the pattern already used in pool.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5746435 commit 85269e2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/dqliteclient/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""High-level connection interface for dqlite."""
22

33
import asyncio
4+
import contextlib
45
from collections.abc import AsyncIterator, Sequence
56
from contextlib import asynccontextmanager
67
from typing import Any
@@ -211,10 +212,9 @@ async def transaction(self) -> AsyncIterator[None]:
211212
yield
212213
await self.execute("COMMIT")
213214
except Exception:
214-
try:
215+
# Swallow rollback failure; original exception is more important
216+
with contextlib.suppress(Exception):
215217
await self.execute("ROLLBACK")
216-
except Exception:
217-
pass # Swallow rollback failure; original exception is more important
218218
raise
219219
finally:
220220
self._in_transaction = False

0 commit comments

Comments
 (0)