Skip to content

Commit 859c2fe

Browse files
Use PEP 249 sequence signature for AsyncAdaptedCursor.setinputsizes
The SQLAlchemy adapter previously used a variadic signature (*inputsizes: Any) that accepts unpacked positional arguments. PEP 249 and the sibling dqlitedbapi cursors use a single-sequence parameter. Align the adapter so callers programming against any of the three cursors use the same shape; body remains a no-op because dqlite's wire encoder has no per-parameter sizing hook. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ca82cd2 commit 859c2fe

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/sqlalchemydqlite/aio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ def fetchall(self) -> Sequence[Any]:
9999
self._rows.clear()
100100
return retval
101101

102-
def setinputsizes(self, *inputsizes: Any) -> None:
102+
def setinputsizes(self, sizes: Sequence[Any]) -> None:
103+
# PEP 249: called before execute*() to hint bind-parameter sizes.
104+
# dqlite's wire encoder does not use per-parameter sizing hints,
105+
# so the implementation is a no-op — but the signature matches
106+
# the standard and the sibling cursors in dqlitedbapi.
103107
pass
104108

105109
def setoutputsize(self, size: int, column: int | None = None) -> None:

tests/test_async_adapter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,22 @@ def test_all_includes_adapter_classes(self) -> None:
211211

212212
expected = {"AsyncAdaptedConnection", "AsyncAdaptedCursor", "DqliteDialect_aio"}
213213
assert expected.issubset(set(aio_mod.__all__))
214+
215+
216+
class TestAioCursorSetInputSizes:
217+
"""PEP 249 conformance: setinputsizes takes a single sequence."""
218+
219+
def test_accepts_single_sequence_argument(self) -> None:
220+
from sqlalchemydqlite.aio import AsyncAdaptedCursor
221+
222+
cursor = AsyncAdaptedCursor.__new__(AsyncAdaptedCursor)
223+
cursor.setinputsizes([10, None, 20]) # no error
224+
225+
def test_extra_positional_argument_rejected(self) -> None:
226+
import pytest
227+
228+
from sqlalchemydqlite.aio import AsyncAdaptedCursor
229+
230+
cursor = AsyncAdaptedCursor.__new__(AsyncAdaptedCursor)
231+
with pytest.raises(TypeError):
232+
cursor.setinputsizes([10], 20) # type: ignore[call-arg]

0 commit comments

Comments
 (0)