Skip to content

Commit 85c55b5

Browse files
authored
refactor: refactor cursor exit (#79)
1 parent 5d06b9e commit 85c55b5

File tree

10 files changed

+10
-19
lines changed

10 files changed

+10
-19
lines changed

sqlspec/adapters/adbc/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ def __enter__(self) -> "Cursor":
335335
self.cursor = self.connection.cursor()
336336
return self.cursor
337337

338-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
339-
_ = (exc_type, exc_val, exc_tb)
338+
def __exit__(self, *_: Any) -> None:
340339
if self.cursor is not None:
341340
with contextlib.suppress(Exception):
342341
self.cursor.close() # type: ignore[no-untyped-call]

sqlspec/adapters/aiosqlite/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ async def __aenter__(self) -> "aiosqlite.Cursor":
6666
self.cursor = await self.connection.cursor()
6767
return self.cursor
6868

69-
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
70-
_ = (exc_type, exc_val, exc_tb)
69+
async def __aexit__(self, *_: Any) -> None:
7170
if self.cursor is not None:
7271
with contextlib.suppress(Exception):
7372
await self.cursor.close()

sqlspec/adapters/asyncmy/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ async def __aenter__(self) -> Union[Cursor, DictCursor]:
6666
self.cursor = self.connection.cursor()
6767
return self.cursor
6868

69-
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
70-
_ = (exc_type, exc_val, exc_tb)
69+
async def __aexit__(self, *_: Any) -> None:
7170
if self.cursor is not None:
7271
await self.cursor.close()
7372

sqlspec/adapters/asyncpg/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def __init__(self, connection: "AsyncpgConnection") -> None:
6363
async def __aenter__(self) -> "AsyncpgConnection":
6464
return self.connection
6565

66-
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
67-
_ = (exc_type, exc_val, exc_tb)
66+
async def __aexit__(self, *_: Any) -> None: ...
6867

6968

7069
class AsyncpgExceptionHandler:

sqlspec/adapters/bigquery/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def __init__(self, connection: "BigQueryConnection") -> None:
177177
def __enter__(self) -> "BigQueryConnection":
178178
return self.connection
179179

180-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
180+
def __exit__(self, *_: Any) -> None:
181181
"""Clean up cursor resources including active QueryJobs."""
182182
if self.job is not None:
183183
try:

sqlspec/adapters/duckdb/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def __enter__(self) -> Any:
6060
self.cursor = self.connection.cursor()
6161
return self.cursor
6262

63-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
64-
_ = (exc_type, exc_val, exc_tb)
63+
def __exit__(self, *_: Any) -> None:
6564
if self.cursor is not None:
6665
self.cursor.close()
6766

sqlspec/adapters/oracledb/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def __enter__(self) -> Cursor:
6363
self.cursor = self.connection.cursor()
6464
return self.cursor
6565

66-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
67-
_ = (exc_type, exc_val, exc_tb) # Mark as intentionally unused
66+
def __exit__(self, *_: Any) -> None:
6867
if self.cursor is not None:
6968
self.cursor.close()
7069

sqlspec/adapters/psqlpy/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,14 @@ async def __aenter__(self) -> "PsqlpyConnection":
238238
self._in_use = True
239239
return self.connection
240240

241-
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
241+
async def __aexit__(self, *_: Any) -> None:
242242
"""Exit cursor context.
243243
244244
Args:
245245
exc_type: Exception type
246246
exc_val: Exception value
247247
exc_tb: Exception traceback
248248
"""
249-
_ = (exc_type, exc_val, exc_tb)
250249
self._in_use = False
251250

252251
def is_in_use(self) -> bool:

sqlspec/adapters/psycopg/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def __enter__(self) -> Any:
125125
self.cursor = self.connection.cursor()
126126
return self.cursor
127127

128-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
129-
_ = (exc_type, exc_val, exc_tb)
128+
def __exit__(self, *_: Any) -> None:
130129
if self.cursor is not None:
131130
self.cursor.close()
132131

sqlspec/adapters/sqlite/driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ def __enter__(self) -> "sqlite3.Cursor":
7575
self.cursor = self.connection.cursor()
7676
return self.cursor
7777

78-
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
78+
def __exit__(self, *_: Any) -> None:
7979
"""Clean up cursor resources.
8080
8181
Args:
8282
exc_type: Exception type if an exception occurred
8383
exc_val: Exception value if an exception occurred
8484
exc_tb: Exception traceback if an exception occurred
8585
"""
86-
_ = (exc_type, exc_val, exc_tb)
8786
if self.cursor is not None:
8887
with contextlib.suppress(Exception):
8988
self.cursor.close()

0 commit comments

Comments
 (0)