typesense-python icon indicating copy to clipboard operation
typesense-python copied to clipboard

feat: add async support

Open tharropoulos opened this issue 1 month ago • 0 comments

Change Summary

This PR migrates the Typesense Python client from requests to httpx and adds async support across all client components. The library now supports both synchronous and asynchronous operations.

Core Changes

  • Migrate HTTP client from requests to httpx for sync operations
  • Add AsyncApiCall class for async HTTP operations
  • Refactor RequestHandler to support both sync (httpx.Client) and async (httpx.AsyncClient) clients
  • Update test dependencies: replace requests-mock with respx for mocking httpx requests
  • Add pytest-asyncio for async test support

Async Client

  • Add AsyncClient class as the main entry point for async operations
  • Add async versions of all resource classes

Type System Improvements

  • Make TDoc TypeVar covariant in Collection and Collections classes for better type flexibility
  • Remove redundant from __future__ import annotations imports

Testing

  • Add async test fixtures for all async components
  • Add async integration tests mirroring existing sync tests
  • Remove redundant mocked tests in favor of integration tests

Dependencies

  • Add httpx as core dependency
  • Add respx and pytest-asyncio for testing
  • Update various dependency versions

Notes

  • All async classes follow the same API patterns as their sync counterparts
  • The async client supports async context management via async with

PR Checklist

tharropoulos avatar Dec 08 '25 18:12 tharropoulos