Add AsyncVisorClient and transport layer#4
Merged
Conversation
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
force-pushed
the
step-7-async-client
branch
from
June 12, 2026 22:51
47643ba to
88a1f6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/visor/_transport.py—AsyncVisorTransportandSyncVisorTransportwith typed HTTP error dispatch and_parse_retry_afterhelper. Error envelope parsing uses explicit shape-checking (not a broadexcept Exception) so malformed envelopes surface asunknown_errorrather than being silently collapsed.src/visor/_client.py—AsyncVisorClientonly (syncVisorClientdeferred to step 11). Readsapi_keyfrom constructor arg orVISOR_API_KEYenv var; raisesValueErrorif neither is set. All 8 endpoints across Inventory, Dealers, and Usage resource groups.AsyncVisorClientfrom the package root (from visor import AsyncVisorClientnow works).tests/test_client_async.py— 32 tests covering constructor variants, auth header propagation, every endpoint path and param serialization,includecomma-joining, usage date/metering_class params, all 7 HTTP error status codes,retry_afteron 429,VisorTransportErroron network failure, and context manager cleanup.Test plan
pytest— 82 tests passruff check .— cleanruff format --check .— cleanmypy src/— clean🤖 Generated with Claude Code