-
Notifications
You must be signed in to change notification settings - Fork 5
Improve public API surface and top-level exports #94
Description
Summary
Key classes that users need regularly are not exported from the top-level package, forcing users to know internal module paths. Additionally, the library lacks common Python conventions like environment variable configuration and a __version__ attribute.
Current Problems
1. Missing top-level exports
mapepire_python/__init__.py currently exports:
__all__ = [
"apilevel", "threadsafety", "paramstyle",
"DatabaseError", "DataError", "Error", "InterfaceError",
"InternalError", "NotSupportedError", "OperationalError",
"ProgrammingError", "IntegrityError", "Warning",
"CONNECTION_CLOSED", "convert_runtime_errors",
"connect", "Connection", "Cursor",
]Missing exports that users need:
DaemonServer— the primary credentials class (users must dofrom mapepire_python.data_types import DaemonServer)SQLJob— the core sync client (from mapepire_python.client.sql_job import SQLJob)PoolJob— the core async client (from mapepire_python.pool.pool_job import PoolJob)Pool,PoolOptions— connection pooling (from mapepire_python.pool.pool_client import Pool)QueryOptions— query configurationQueryState,JobStatus— useful enums for checking stateQueryResult— the result type users work with
2. No __version__ attribute
Version is defined in version.py but not re-exported:
# Users expect this to work:
import mapepire_python
print(mapepire_python.__version__) # AttributeError3. No environment variable configuration
Most Python database clients support environment variables for connection configuration (psycopg2, asyncpg, etc.). mapepire-python requires explicit credentials in every call.
Proposed environment variables:
MAPEPIRE_HOST— server hostnameMAPEPIRE_PORT— server port (default: 8076)MAPEPIRE_USER— database userMAPEPIRE_PASSWORD— database passwordMAPEPIRE_CA_PATH— path to CA certificate file
This enables:
# With env vars set, just:
with connect() as conn:
result = conn.execute("SELECT ...").fetchone()4. No async connect() at the top level
The async connection requires a separate import:
from mapepire_python.asyncio.connection import connect # Not discoverableShould be accessible as:
from mapepire_python import async_connect
# or
from mapepire_python.asyncio import connectProposed Changes
-
Add missing classes to
__init__.py__all__:DaemonServer,SQLJob,PoolJob,Pool,PoolOptionsQueryOptions,QueryResult,QueryState,JobStatus
-
Add
__version__re-exported fromversion.py -
Add environment variable support to
DaemonServerorconnect():- Fall back to env vars when parameters are not provided
- Document the supported env var names
-
Add
async_connectto top-level exports or document the async import path clearly
Files to Modify
mapepire_python/__init__.py— Add exports,__version__,async_connectmapepire_python/data_types.py— Add env var fallback toDaemonServermapepire_python/base_job.py— Support env var config in_parse_connection_input()
Acceptance Criteria
- All commonly-used classes importable from
mapepire_pythondirectly -
mapepire_python.__version__returns the current version string -
connect()works with no arguments when env vars are set - Async connect is accessible from a documented top-level path
- Existing tests still pass
- README updated with new import patterns and env var documentation