Step 18: transport robustness, typing cleanup, and coverage polish#13
Merged
Conversation
- Wrap 2xx malformed JSON in VisorTransportError instead of leaking a raw JSONDecodeError from the success path - Replace bare `dict` return annotations with `dict[str, Any]` in _transport.py; drop type: ignore[type-arg] and type: ignore[no-any-return] - Add Retry-After HTTP-date and invalid-value tests (async + sync); _transport.py now at 100% coverage - Add snapshot_date serialization, include serialization, and empty-list omission tests in test_filter_model.py - Document unreachable sold_within_days+snapshot_date mutual-exclusion branch with an explanatory comment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Capture response.json() as Any, then cast to dict[str, Any] before returning, eliminating the suppression comment added in step 18. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace cast(dict[str, Any], data) with an isinstance check that raises VisorTransportError for successful responses that are not JSON objects. Removes cast import. Adds sync and async tests for the new guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
_handle_response()now wrapsresponse.json()parse failures inVisorTransportErrorinstead of leaking a rawJSONDecodeErrorfrom the success pathisinstance(data, dict)guard that raisesVisorTransportErrorfor successful responses that are not JSON objects (e.g. arrays), enforcing the transport contract at runtime withoutcast()dictreturn annotations withdict[str, Any]across_transport.py; removed alltype: ignoresuppressionsNone);_transport.pynow at 100% coveragesnapshot_dateISO serialization,includecomma-joining, and empty-list param omissionsold_within_days + snapshot_datemutual-exclusion branch in_base.pyTest plan
pytest --cov=visor --cov-report=term-missing— 243 passed,_transport.py100%ruff check src/ tests/— cleanruff format --check src/ tests/— cleanmypy src/— cleanpython -m build+twine check dist/*— both passedvisor/py.typedpresent in wheelDesign Docs/andFIXESabsent from sdist🤖 Generated with Claude Code