Skip to content

Deduplicate httpx Timeout construction with match helper in transports #2960

@adamtheturtle

Description

@adamtheturtle

Summary

Deduplicate httpx timeout construction in vws/transports.py where HTTPXTransport.__call__ and AsyncHTTPXTransport.__call__ each use the same isinstance(request_timeout, tuple) branch.

Precise locations

  • File: src/vws/transports.py
  • HTTPXTransport.__call__: lines 152–166 (approx.)
  • AsyncHTTPXTransport.__call__: lines 275–289 (approx.)

Suggested approach

  1. Add a private helper, e.g. _httpx_timeout(request_timeout: float | tuple[float, float]) -> httpx.Timeout, implemented with match request_timeout::
    • case (connect, read): → per-field timeouts
    • case float() | int() as t: → symmetric connect/read (today only float in the annotation, but runtime may pass int from callers — preserve current coercion behavior)
  2. Call the helper from both transport classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions