Add proxy, hooks, circuit breaker, cache, batch helpers, and examples#32
Merged
jackparnell merged 3 commits intomainfrom Apr 12, 2026
Merged
Add proxy, hooks, circuit breaker, cache, batch helpers, and examples#32jackparnell merged 3 commits intomainfrom
jackparnell merged 3 commits intomainfrom
Conversation
Features: 1. Proxy support — proxy= param routes requests through HTTP/HTTPS proxies 2. Idempotency keys — X-Idempotency-Key header on POST requests 3. SDK-level hooks — on_request/on_response callbacks for custom metrics 4. Circuit breaker — enable_circuit_breaker(N) fails fast after N failures 5. Response caching — enable_cache(ttl) caches GET responses in memory 6. Batch helpers — get_posts_by_ids/get_users_by_ids with 404 skipping 7. py.typed marker verified 8. Examples directory — 6 runnable scripts (basic, typed, async, webhook, mock testing, hooks) All features on both sync and async clients. 342 tests, 99% coverage. Updated CHANGELOG and README. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Test proxy code path uses ProxyHandler + build_opener - Test async on_request and on_response hooks fire correctly - Test async get_posts_by_ids skips 404s 346 tests pass, 100% coverage across all modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New file: tests/integration/test_v170_features.py (16 tests) - TestTypedModeIntegration — confirms Post/User/Comment models populate correctly from real API responses (catches schema drift that mocked unit tests miss) - TestRateLimitHeadersIntegration — confirms server emits X-RateLimit-* headers and we parse them as ints - TestBatchHelpersIntegration — get_posts_by_ids / get_users_by_ids against real IDs, including 404 skip behaviour Expanded: tests/integration/test_async.py (+19 tests) - TestAsyncComments, TestAsyncVotingAndReactions, TestAsyncNotifications, TestAsyncColonies, TestAsyncFollowing, TestAsyncWebhooks, TestAsyncProfile - Plus async coverage for v1.7.0: TestAsyncBatchHelpers, TestAsyncRateLimitHeaders, TestAsyncTypedMode Closes the major async parity gaps identified in the audit (was ~10 tests covering core methods only; now 27 tests covering comments, voting, reactions, notifications, colonies, following, webhooks, profile updates, batch helpers, rate limits, and typed mode). Also: extend items_of() helper in conftest to recognise the "data" key, which AsyncColonyClient uses to wrap bare-list responses. All 43 new+existing integration tests pass against the live API (3 skip when COLONY_TEST_API_KEY_2 is unset). Co-Authored-By: Claude Opus 4.6 (1M context) <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
Completes the v1.7.0 feature set with 9 additions:
proxy="http://proxy:8080"param on both clientsX-Idempotency-Keyheader on POST requests to prevent duplicate createson_request(callback)/on_response(callback)for custom metrics/loggingenable_circuit_breaker(5)— fail fast after N consecutive failuresenable_cache(ttl=60)— in-memory cache for GET requests with TTLget_posts_by_ids()/get_users_by_ids()— fetch multiple, skip 404sAll features available on both sync (
ColonyClient) and async (AsyncColonyClient).Changes
client.py— +168 lines (proxy, hooks, circuit breaker, cache, batch helpers)async_client.py— +76 lines (hooks, circuit breaker, batch helpers)tests/test_advanced.py— 28 new testsexamples/— 6 new filesTest plan
🤖 Generated with Claude Code