feat(python): add aiohttp auto-detection to Python SDK generator#13586
Merged
feat(python): add aiohttp auto-detection to Python SDK generator#13586
Conversation
|
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage. Once credits are available, reopen this pull request to trigger a review. |
1313402 to
8aa128a
Compare
8aa128a to
0bab983
Compare
2 tasks
When httpx_aiohttp is installed, the async client automatically uses it instead of plain httpx.AsyncClient. Adds DefaultAioHttpClient and DefaultAsyncHttpxClient convenience classes with SDK defaults.
…pass Fix mypy errors by adding type: ignore comments for optional httpx_aiohttp imports and widening timeout param to Optional[float]. Add conftest hook to auto-skip @pytest.mark.aiohttp tests when the package is missing. Update CI to run a second test pass after installing the aiohttp extra.
…dule pollution Co-Authored-By: bot_apk <apk@cognition.ai>
…h internal process timeout The python remote generation can take >60s, causing the vitest 60s timeout to fire before cliV2.generate's internal 180s process timeout. Increased both python and go basic generation test timeouts to 180_000ms to match. Co-Authored-By: bot_apk <apk@cognition.ai>
Add aiohttp as explicit optional dep alongside httpx-aiohttp, bump httpx-aiohttp floor to >=0.1.8, and tighten _make_default_async_client timeout param to non-optional float.
- Move `import seed._default_clients` before `mock.patch.dict` so the module stays in sys.modules after the context manager restores state, fixing the ImportError on cleanup reload - Revert _make_default_async_client timeout param to Optional[float] to satisfy mypy (the ternary _defaulted_timeout can't be narrowed) - Update poetry.lock for new aiohttp optional dep
e4352e5 to
645e614
Compare
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
- Merge user-defined extras with built-in aiohttp deps instead of overwriting - Validate package_name before interpolating into generated test code - Fix no-op bypass test to actually verify _make_default_async_client is skipped - Add versions.yml changelog entry for the aiohttp auto-detection feature
fern-support
approved these changes
Apr 2, 2026
generators/python/src/fern_python/generators/sdk/sdk_generator.py
Outdated
Show resolved
Hide resolved
…tection - Remove unnecessary module_path validation that defended against a non-applicable code injection threat (module_path comes from user's own Fern config, not untrusted input) - Generate minimal tests/conftest.py with aiohttp skip hook for non-wire-test projects so @pytest.mark.aiohttp tests are auto-skipped when httpx_aiohttp is not installed (wire-test projects already get this from WireTestSetupGenerator)
generators/python/src/fern_python/generators/sdk/sdk_generator.py
Outdated
Show resolved
Hide resolved
The generated aiohttp test was hardcoding `from {module_path}.client`
but the SDK generator supports custom client filenames via
`client_filename` or `client.filename` config. Derive the module name
from the configured filename so the test imports resolve correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Auto-detect
httpx_aiohttpat runtime and use it for the async HTTP client when available, falling back to plainhttpx.AsyncClient.Changes Made
_make_default_async_client()helper inclient.pythat trieshttpx_aiohttp.HttpxAiohttpClientfirst, falling back tohttpx.AsyncClient_default_clients.pymodule withDefaultAioHttpClientandDefaultAsyncHttpxClientclasses with SDK-appropriate defaultsaiohttpandhttpx-aiohttpas optional deps exposed via a[aiohttp]pip extra inpyproject.toml; correctly excluded fromrequirements.txt@pytest.mark.aiohttpmarker, auto-skip logic inconftest.py, and a mock-based bypass testpytest -m aiohttpafter installing the extrapackage_namevalidation before f-string interpolation in generated test files; merge (not overwrite) user-defined extrasversions.ymlentry for v5.3.0cliV2.generateprocess timeoutTesting
pytest -m "not aiohttp"— fallback behavior without httpx_aiohttppip install httpx-aiohttp && pytest -m "aiohttp"— autodetect with httpx_aiohttp installedseed/python-sdk/exhaustive/no-custom-config)test-eteCI check passes with increased timeoutsLink to Devin session: https://app.devin.ai/sessions/2562e5b9bd6a4be7a5756c141751c323