Skip to content

Commit c29ebc4

Browse files
Re-export stdlib-parity NotSupportedError stubs to dqlitedbapi.aio
ISSUE-Q8 mirrored register_adapter to the async surface but did not extend the mirror to register_converter / complete_statement / enable_callback_tracebacks. A cross-driver caller porting from aiosqlite (which mirrors stdlib's full register_* surface) hit AttributeError on the async path — escaping the dbapi.Error hierarchy that the sync stubs were specifically introduced for. Re-export the three sync-surface stubs into dqlitedbapi.aio and add them to __all__. Symmetric with the existing register_adapter mirror. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f85742c commit c29ebc4

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

src/dqlitedbapi/aio/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
import logging
44
from typing import Final, Literal
55

6-
from dqlitedbapi import __version__
6+
# Re-export the stdlib-sqlite3-parity NotSupportedError stubs from
7+
# the sync surface so cross-driver code porting from aiosqlite (which
8+
# mirrors stdlib's full register_* / complete_statement /
9+
# enable_callback_tracebacks surface) gets a clean
10+
# ``dbapi.NotSupportedError`` rather than ``AttributeError`` —
11+
# matching the discipline applied to ``register_adapter`` (ISSUE-Q8).
12+
from dqlitedbapi import ( # noqa: E402 — module-level re-export
13+
__version__,
14+
complete_statement,
15+
enable_callback_tracebacks,
16+
register_converter,
17+
)
718
from dqlitedbapi._constants import (
819
SQLITE_VERSION as _SQLITE_VERSION,
920
)
@@ -116,6 +127,13 @@
116127
# Type-adapter registry (shared module-global with the sync
117128
# surface; calling on either namespace mutates the same dict)
118129
"register_adapter",
130+
# NotSupportedError stubs mirroring stdlib sqlite3 — symmetric
131+
# with the sync surface so cross-driver code porting from
132+
# aiosqlite / stdlib gets a dbapi.Error rather than
133+
# AttributeError.
134+
"register_converter",
135+
"complete_statement",
136+
"enable_callback_tracebacks",
119137
]
120138

121139

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Pin: the async surface re-exports the stdlib-sqlite3-parity
2+
NotSupportedError stubs that the sync surface already provides.
3+
4+
ISSUE-Q8 mirrored ``register_adapter`` to the async surface; this
5+
finishes the symmetry for ``register_converter`` /
6+
``complete_statement`` / ``enable_callback_tracebacks`` so a
7+
cross-driver caller porting from aiosqlite gets a
8+
``dbapi.NotSupportedError`` rather than ``AttributeError``
9+
(which escapes the dbapi.Error hierarchy).
10+
"""
11+
12+
import pytest
13+
14+
import dqlitedbapi.aio
15+
from dqlitedbapi.exceptions import NotSupportedError
16+
17+
18+
def test_aio_register_converter_raises_notsupported() -> None:
19+
with pytest.raises(NotSupportedError):
20+
dqlitedbapi.aio.register_converter("DATE", lambda b: b)
21+
22+
23+
def test_aio_complete_statement_raises_notsupported() -> None:
24+
with pytest.raises(NotSupportedError):
25+
dqlitedbapi.aio.complete_statement("SELECT 1;")
26+
27+
28+
def test_aio_enable_callback_tracebacks_raises_notsupported() -> None:
29+
with pytest.raises(NotSupportedError):
30+
dqlitedbapi.aio.enable_callback_tracebacks(True)
31+
32+
33+
def test_aio_all_includes_the_three_stubs() -> None:
34+
assert "register_converter" in dqlitedbapi.aio.__all__
35+
assert "complete_statement" in dqlitedbapi.aio.__all__
36+
assert "enable_callback_tracebacks" in dqlitedbapi.aio.__all__

0 commit comments

Comments
 (0)