Fix branch coverage in timeout handling#2923
Merged
adamtheturtle merged 1 commit intomainfrom Feb 15, 2026
Merged
Conversation
The isinstance check for tuple[1] is always true when timeout is a tuple, as the requests library always provides numeric values. Removing this redundant check eliminates uncovered branch warnings during coverage analysis. Co-Authored-By: Claude Opus 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
timeoutvariable with explicit types so pyright can narrow through tuple element access without needingtype: ignoreorcastisinstancechecks into two sequentialifstatements, which eliminates the uncoverable false branch (the innerisinstance(timeout[1], (int, float))was always true when reached)Test plan
TestResponseDelaytests pass🤖 Generated with Claude Code
Note
Low Risk
Small refactor in mock response-delay timeout logic; behavior should be equivalent aside from clearer tuple timeout handling and is covered by existing timeout tests.
Overview
Adjusts
_wrap_callbacktimeout handling insrc/mock_vws/_requests_mock_server/decorators.pyto improve type narrowing and remove an effectively dead branch.timeoutis now explicitly typed, tuple timeouts are flattened by extracting the read-timeout element first, and the effective timeout is computed via a singleisinstancecheck before potentially sleeping and raisingrequests.exceptions.Timeout.Written by Cursor Bugbot for commit 3586524. This will update automatically on new commits. Configure here.