Skip to content

Add AsyncVisorClient and transport layer#4

Merged
whitewalls86 merged 2 commits into
masterfrom
step-7-async-client
Jun 12, 2026
Merged

Add AsyncVisorClient and transport layer#4
whitewalls86 merged 2 commits into
masterfrom
step-7-async-client

Conversation

@whitewalls86

Copy link
Copy Markdown
Owner

Summary

  • Implements src/visor/_transport.pyAsyncVisorTransport and SyncVisorTransport with typed HTTP error dispatch and _parse_retry_after helper. Error envelope parsing uses explicit shape-checking (not a broad except Exception) so malformed envelopes surface as unknown_error rather than being silently collapsed.
  • Implements src/visor/_client.pyAsyncVisorClient only (sync VisorClient deferred to step 11). Reads api_key from constructor arg or VISOR_API_KEY env var; raises ValueError if neither is set. All 8 endpoints across Inventory, Dealers, and Usage resource groups.
  • Exports AsyncVisorClient from the package root (from visor import AsyncVisorClient now works).
  • Adds tests/test_client_async.py — 32 tests covering constructor variants, auth header propagation, every endpoint path and param serialization, include comma-joining, usage date/metering_class params, all 7 HTTP error status codes, retry_after on 429, VisorTransportError on network failure, and context manager cleanup.

Test plan

  • pytest — 82 tests pass
  • ruff check . — clean
  • ruff format --check . — clean
  • mypy src/ — clean

🤖 Generated with Claude Code

whitewalls86 and others added 2 commits June 12, 2026 17:50
Implements _transport.py (AsyncVisorTransport + SyncVisorTransport with
typed error dispatch) and _client.py (AsyncVisorClient only — all 8
endpoints across Inventory, Dealers, and Usage resource groups).
32 new tests in test_client_async.py cover constructors, auth header
propagation, every endpoint path and param serialization, error dispatch
for all HTTP status codes, and context manager cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Export AsyncVisorClient from the package root so `from visor import
AsyncVisorClient` works. Narrow the broad `except Exception` in
_handle_response to `except ValueError` for JSON decode failures only,
then explicitly check the envelope shape before accessing .get("error")
so malformed envelopes like {"error": "oops"} are caught and surfaced
as unknown_error rather than silently collapsed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@whitewalls86
whitewalls86 force-pushed the step-7-async-client branch from 47643ba to 88a1f6a Compare June 12, 2026 22:51
@whitewalls86
whitewalls86 merged commit 3dc9107 into master Jun 12, 2026
2 checks passed
@whitewalls86
whitewalls86 deleted the step-7-async-client branch June 12, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant