Refactor timeout and body handling to use match statements#3112
Merged
adamtheturtle merged 3 commits intomainfrom Apr 15, 2026
Merged
Refactor timeout and body handling to use match statements#3112adamtheturtle merged 3 commits intomainfrom
adamtheturtle merged 3 commits intomainfrom
Conversation
Replace isinstance chains with match/case for timeout normalization and request body conversion in _wrap_callback. Closes #3110 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The original else branch handled any type, not just bytes(). Using case _ preserves that catch-all semantics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b4cfed0. Configure here.
Match only int/float read values in the tuple case, so (5, None) falls through to effective = None instead of raising TypeError. 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
isinstancechains withmatch/casefor timeout normalization and request body → bytes conversion in_wrap_callbackCloses #3110
Test plan
🤖 Generated with Claude Code
Note
Low Risk
Pure refactor of request timeout and body parsing in the mock callback wrapper; low risk aside from potential edge-case differences when
timeouttuples or unusual body types are passed.Overview
Refactors
_wrap_callbackinsrc/mock_vws/_requests_mock_server/decorators.pyto replaceisinstancechains withmatch/casefor (1) normalizingrequeststimeoutvalues (including(connect, read)tuples) into an effective read-timeout and (2) convertingrequest.bodyintobytes.Behavior is intended to stay the same, but tuple handling is now pattern-matched (only treating
(…, number)as a read timeout) and body handling is expressed via explicitNone/strcases with a fallback to the original body value.Reviewed by Cursor Bugbot for commit 3d57724. Bugbot is set up for automated code reviews on this repo. Configure here.