Skip to content

Deduplicate httpx Timeout construction with match helper#2961

Closed
adamtheturtle wants to merge 4 commits intomainfrom
adamtheturtle/dedup-httpx-timeout
Closed

Deduplicate httpx Timeout construction with match helper#2961
adamtheturtle wants to merge 4 commits intomainfrom
adamtheturtle/dedup-httpx-timeout

Conversation

@adamtheturtle
Copy link
Copy Markdown
Member

@adamtheturtle adamtheturtle commented Apr 15, 2026

Summary

  • Extract _httpx_timeout() helper using match/case to build httpx.Timeout, replacing duplicated isinstance branches in HTTPXTransport.__call__ and AsyncHTTPXTransport.__call__

Closes #2960

Test plan

  • Verified helper produces identical httpx.Timeout values for both float and tuple inputs
  • All pre-commit hooks pass (ruff, mypy, pyright, ty, pyrefly, vulture, etc.)

🤖 Generated with Claude Code


Note

Low Risk
Low risk refactor confined to httpx transport timeout construction; behavior should remain the same aside from stricter type handling via the new helper.

Overview
Refactors HTTPXTransport and AsyncHTTPXTransport to use a new _httpx_timeout() helper for constructing httpx.Timeout, removing duplicated isinstance branches.

The helper uses match/case to handle (connect, read) tuples vs scalar timeouts and adds an assert_never fallback to make unsupported types explicit.

Reviewed by Cursor Bugbot for commit 4940fcb. Bugbot is set up for automated code reviews on this repo. Configure here.

adamtheturtle and others added 2 commits April 15, 2026 06:12
Extract _httpx_timeout() helper using match/case to build
httpx.Timeout, replacing duplicated isinstance branches in
HTTPXTransport and AsyncHTTPXTransport.

Closes #2960

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
adamtheturtle and others added 2 commits April 15, 2026 06:18
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@adamtheturtle
Copy link
Copy Markdown
Member Author

Blocked on type checker bugs with match/case narrowing:

Will revisit once these are resolved.

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.

Deduplicate httpx Timeout construction with match helper in transports

1 participant