You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(client): constructor-injectable config, lazy settings, single close path
Implements plans/refactor/03-client-config-lifecycle.md:
- config.py no longer instantiates Settings() at import time; token is
optional on the Settings model. 'import codesphere' now succeeds
without any environment variables
- CodesphereSDK(token=..., base_url=..., timeout=..., http_client=...)
with resolution order: explicit argument > CS_* env (.env honored) >
built-in default. A missing token raises AuthenticationError at
construction (previously a raw pydantic ValidationError at import;
the purpose-built exception was never raised)
- Fix dead CS_BASE_URL: the transport no longer defaults its own
base_url, so the configured value actually applies; two SDK instances
with different tokens/URLs can now coexist in one process
- APIHttpClient becomes a dumb transport: full config passed in, no
settings access, dynamic get/post/... setattr loop removed, BaseModel
re-dump removed (serialization owned solely by execute_operation)
- One close path: __aexit__ delegates to close(exc_type, exc_val, exc_tb)
on both SDK and transport
- New tests/test_sdk_config.py: import-without-env (empty-env
subprocess), token/base_url/timeout resolution order, two-client
isolation via httpx.MockTransport; conftest fixtures no longer patch
a settings singleton
- config.py and http_client.py removed from the ty ratchet
- README documents constructor configuration
Behavior change (fix): startup failure moves from import time to
CodesphereSDK() construction and is now AuthenticationError.
0 commit comments