Skip to content

Fix branch coverage in timeout handling#2923

Merged
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/fix-coverage
Feb 15, 2026
Merged

Fix branch coverage in timeout handling#2923
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/fix-coverage

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Feb 15, 2026

Summary

  • Annotate the timeout variable with explicit types so pyright can narrow through tuple element access without needing type: ignore or cast
  • Flatten the nested isinstance checks into two sequential if statements, which eliminates the uncoverable false branch (the inner isinstance(timeout[1], (int, float)) was always true when reached)

Test plan

  • All 6 TestResponseDelay tests pass
  • All pre-commit and pre-push hooks pass (pyright, mypy, ruff, vulture, etc.)

🤖 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_callback timeout handling in src/mock_vws/_requests_mock_server/decorators.py to improve type narrowing and remove an effectively dead branch.

timeout is now explicitly typed, tuple timeouts are flattened by extracting the read-timeout element first, and the effective timeout is computed via a single isinstance check before potentially sleeping and raising requests.exceptions.Timeout.

Written by Cursor Bugbot for commit 3586524. This will update automatically on new commits. Configure here.

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>
@adamtheturtle adamtheturtle merged commit 818f5b2 into main Feb 15, 2026
12 checks passed
@adamtheturtle adamtheturtle deleted the adamtheturtle/fix-coverage branch February 15, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant