Skip to content

πŸ› οΈ HTTPx Adapter Support, πŸ“ Comprehensive Test Suite, πŸ“– Update Examples#7

Open
anthonywu wants to merge 2 commits intomc-fdc-dev:masterfrom
anthonywu:add-httpx-add-tests
Open

πŸ› οΈ HTTPx Adapter Support, πŸ“ Comprehensive Test Suite, πŸ“– Update Examples#7
anthonywu wants to merge 2 commits intomc-fdc-dev:masterfrom
anthonywu:add-httpx-add-tests

Conversation

@anthonywu
Copy link

Hey maintainers - I thought this library had a solid foundation and I could improve on it instead of creating my own or forking it.

I would like to offer to be co-owner/publisher to the pypi releases, if the pypi owner would consider. I have worked in Python for 17 years, including full time Python dev at Google/YouTube/Apple and responsible for large python deployments.

If I co-own the project and publishing I would be willing to continue modernizing this library - e.g. taking this library to Python 3.11+ with type hints, more linting/tests and of course be co-responsible for bug reports. If not, that's no problem, this Httpx upgrade adds what I need for now and I'm happy to stop here.


Summary

Added HTTPx adapter support for both sync and async operations, implemented a comprehensive test suite for all adapters, and improved resource management across the library.

Key Changes

New HTTPx Adapter

  • Added HttpxAdapter class supporting both sync and async modes
  • Works with any async framework (asyncio, trio, curio) via anyio
  • Provides search(), search_async(), and asearch() methods
  • Full feature parity with existing adapters

Comprehensive Test Suite

  • Created dedicated test files for each adapter (test_adapter_requests.py, test_adapter_httpx.py, test_adapter_aiohttp.py)
  • Added schema validation tests to ensure API response compliance
  • Implemented cross-adapter consistency tests
  • Added async operation tests with proper event loop handling

Infrastructure Improvements

  • Consolidated shared fixtures into conftest.py following pytest best practices
  • Added easy API call rate limit during testing
  • Implemented context manager support for all adapters for proper resource cleanup

Bug Fixes

  • Fixed limit parameter in async iterators to yield exact count
  • Corrected async generator usage in example code

API Enhancements

  • Made adapter initialization parameters optional with environment variable defaults read
  • Maintained full backward compatibility (I hope, tried to minimize touching aiohttp except fixing test expectations)

Testing

All 36 tests passing across three adapter implementations with proper async support and rate limit protection.

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