Skip to content

Commit b7f14e1

Browse files
Cycle 14: constructor ValueError → ProgrammingError at DBAPI boundary
Per PEP 249, ProgrammingError covers programming-level mistakes at the API (bad argument types, bad parameter shapes, etc.). timeout=-1 is exactly that. ValueError leaked out of the dbapi's public connect()/Connection()/AsyncConnection() surface; swap to ProgrammingError for hierarchy consistency. Client layer keeps ValueError — it's pre-DBAPI, below the PEP 249 surface, and ValueError is right there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b886518 commit b7f14e1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/dqlitedbapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ def connect(
104104
import math
105105

106106
if not math.isfinite(timeout) or timeout <= 0:
107-
raise ValueError(f"timeout must be a positive finite number, got {timeout}")
107+
raise ProgrammingError(f"timeout must be a positive finite number, got {timeout}")
108108
return Connection(address, database=database, timeout=timeout)

src/dqlitedbapi/aio/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import dqliteclient.exceptions as _client_exc
99
from dqliteclient import DqliteConnection
1010
from dqlitedbapi.aio.cursor import AsyncCursor
11-
from dqlitedbapi.exceptions import InterfaceError, OperationalError
11+
from dqlitedbapi.exceptions import InterfaceError, OperationalError, ProgrammingError
1212

1313

1414
class AsyncConnection:
@@ -33,7 +33,7 @@ def __init__(
3333
``None`` disables the cap.
3434
"""
3535
if not math.isfinite(timeout) or timeout <= 0:
36-
raise ValueError(f"timeout must be a positive finite number, got {timeout}")
36+
raise ProgrammingError(f"timeout must be a positive finite number, got {timeout}")
3737
self._address = address
3838
self._database = database
3939
self._timeout = timeout

src/dqlitedbapi/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(
7878
:class:`DqliteConnection`. ``None`` disables the cap.
7979
"""
8080
if not math.isfinite(timeout) or timeout <= 0:
81-
raise ValueError(f"timeout must be a positive finite number, got {timeout}")
81+
raise ProgrammingError(f"timeout must be a positive finite number, got {timeout}")
8282
self._address = address
8383
self._database = database
8484
self._timeout = timeout

0 commit comments

Comments
 (0)