Skip to content

feat(python): add aiohttp auto-detection to Python SDK generator#13586

Merged
jsklan merged 20 commits intomainfrom
jsklan/aiohttp-python
Apr 3, 2026
Merged

feat(python): add aiohttp auto-detection to Python SDK generator#13586
jsklan merged 20 commits intomainfrom
jsklan/aiohttp-python

Conversation

@jsklan
Copy link
Copy Markdown
Contributor

@jsklan jsklan commented Mar 16, 2026

Description

Auto-detect httpx_aiohttp at runtime and use it for the async HTTP client when available, falling back to plain httpx.AsyncClient.

Changes Made

  • Async client auto-detection: Add _make_default_async_client() helper in client.py that tries httpx_aiohttp.HttpxAiohttpClient first, falling back to httpx.AsyncClient
  • Convenience classes: Add _default_clients.py module with DefaultAioHttpClient and DefaultAsyncHttpxClient classes with SDK-appropriate defaults
  • Optional dependencies: Add aiohttp and httpx-aiohttp as optional deps exposed via a [aiohttp] pip extra in pyproject.toml; correctly excluded from requirements.txt
  • Test generation: Generate pytest-based aiohttp tests with @pytest.mark.aiohttp marker, auto-skip logic in conftest.py, and a mock-based bypass test
  • CI two-pass testing: Standard tests then pytest -m aiohttp after installing the extra
  • Generator hardening: Add package_name validation before f-string interpolation in generated test files; merge (not overwrite) user-defined extras
  • Version entry: Add versions.yml entry for v5.3.0
  • ETE timeout fix: Increase vitest timeouts for basic generation tests from 60s → 180s to match internal cliV2.generate process timeout

Testing

  • pytest -m "not aiohttp" — fallback behavior without httpx_aiohttp
  • pip install httpx-aiohttp && pytest -m "aiohttp" — autodetect with httpx_aiohttp installed
  • Seed fixture output validated (seed/python-sdk/exhaustive/no-custom-config)
  • test-ete CI check passes with increased timeouts

Link to Devin session: https://app.devin.ai/sessions/2562e5b9bd6a4be7a5756c141751c323


Open with Devin

@jsklan jsklan self-assigned this Mar 16, 2026
@claude
Copy link
Copy Markdown

claude bot commented Mar 16, 2026

⚠️ Code review skipped — your organization's overage spend limit has been reached.

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.

@devin-ai-integration devin-ai-integration bot force-pushed the jsklan/aiohttp-python branch from 1313402 to 8aa128a Compare March 19, 2026 22:09
devin-ai-integration[bot]

This comment was marked as resolved.

jsklan and others added 7 commits April 2, 2026 14:01
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
)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@jsklan jsklan force-pushed the jsklan/aiohttp-python branch from e4352e5 to 645e614 Compare April 2, 2026 18:02
@jsklan jsklan marked this pull request as ready for review April 2, 2026 18:11
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

hex-security-app[bot]

This comment was marked as resolved.

graphite-app[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

jsklan added 2 commits April 2, 2026 15:45
- 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
@jsklan jsklan changed the title feat(python): add aiohttp auto-detection for async HTTP client feat(python): add aiohttp auto-detection to Python SDK generator Apr 2, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

jsklan added 2 commits April 2, 2026 18:46
…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)
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

jsklan added 2 commits April 2, 2026 19:01
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.
@fern-api fern-api deleted a comment from hex-security-app bot Apr 3, 2026
@jsklan jsklan merged commit d4aaac3 into main Apr 3, 2026
185 of 188 checks passed
@jsklan jsklan deleted the jsklan/aiohttp-python branch April 3, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants