Skip to content

Commit b09a5a3

Browse files
Promote parse_address to public API; fix _check_in_use docstring
The _parse_address helper was the canonical "host:port" parser for DqliteConnection but lived under a leading-underscore name; cycle 20's URL pre-validator and the dbapi entry-points imported it directly across package boundaries, re-introducing the cross-package private-API drift the project's import discipline was designed to discourage. Promote parse_address to public; keep the leading-underscore alias for backwards compatibility. Update the dbapi sync + async entry- points and the SA URL pre-validator to import the public name. Also align the _check_in_use docstring with the four guards the function performs (cycle 20 added the fork-pid check; the docstring still listed three). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 59755ea commit b09a5a3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/dqliteclient/connection.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,19 @@ def _validate_timeout(value: float, *, name: str = "timeout") -> float:
662662
return float(value)
663663

664664

665-
def _parse_address(address: str) -> tuple[str, int]:
665+
def parse_address(address: str) -> tuple[str, int]:
666666
"""Parse a host:port address string, handling IPv6 brackets.
667667
668668
Returns ``(canonical_host, port)``. IP literals are returned in
669669
``ipaddress.ip_address``'s canonical form; hostnames are
670670
lowercased. Invalid hosts (credentials-like '@', whitespace/CRLF,
671671
non-ASCII, empty) raise ``ValueError``.
672+
673+
Public surface: stable across releases. Cross-package consumers
674+
(e.g. the ``sqlalchemy-dqlite`` URL pre-validator) import the
675+
address parser directly so a typoed DSN is rejected at
676+
``create_engine`` time rather than inside a SA retry loop. The
677+
legacy underscore alias is kept for backwards compatibility.
672678
"""
673679
if address.startswith("["):
674680
# Bracketed IPv6: [host]:port. RFC 3986 §3.2.2 reserves the
@@ -760,6 +766,12 @@ def _parse_address(address: str) -> tuple[str, int]:
760766
return host, port
761767

762768

769+
# Backwards-compatible alias for callers that imported the
770+
# leading-underscore name. Kept indefinitely; new callers should
771+
# import ``parse_address``.
772+
_parse_address = parse_address
773+
774+
763775
class DqliteConnection:
764776
"""High-level async connection to a dqlite database.
765777

0 commit comments

Comments
 (0)