Skip to content

refactor: move async dependencies from optional to direct #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 22, 2025

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Jul 21, 2025

Summary

This PR moves starlette, uvicorn, and uvicorn-worker from optional dependencies to direct dependencies, simplifying the installation process for users who need async functionality.

Impact Analysis

  • Installation size increase: < 1MB (specifically 816KB, ~3.5% increase)
  • Base installation: 23MB → With async deps: 24MB
  • Removes the need for pip install functions-framework[async]
  • Maintains Python 3.8+ requirement for these dependencies

Changes

  • Move async dependencies to direct dependencies in pyproject.toml
  • Remove [async] extra dependency configuration
  • Update imports to be direct instead of conditional
  • Remove "Starlette is not installed" error messages
  • Update tests to reflect direct dependency availability

Test Plan

All existing tests pass with 100% coverage. The async functionality remains unchanged, just the installation method is simplified.

taeold added 7 commits July 21, 2025 12:04
Based on dependency analysis, adding starlette, uvicorn, and uvicorn-worker
as direct dependencies only increases installation size by ~816KB (3.5%).
This minimal impact makes it reasonable to include them directly, simplifying
installation for users who need async functionality while maintaining
Python 3.8+ compatibility constraints.
…dencies

- Remove async extras from tox.ini since deps are now direct
- Update _http/__init__.py to import StarletteApplication directly
- Remove try/except ImportError for starlette in aio/__init__.py
- Remove error message about installing with [async] extra
- Update test_asgi.py to import starlette directly
- Remove test_import_error_without_starlette from test_aio.py
- Fix test_http.py monkeypatch to work with direct imports
…sk apps

Reverts the direct import of StarletteApplication to keep it as a dynamic
import. This ensures that Flask-only users don't load the asgi module and
its starlette/uvicorn dependencies unnecessarily.
Since async dependencies are now direct dependencies, we no longer need
to install with [async] extras in the GitHub workflow.
@taeold taeold requested a review from maemayve July 22, 2025 15:21
@taeold taeold merged commit 82ba117 into GoogleCloudPlatform:main Jul 22, 2025
85 of 87 checks passed
@taeold taeold deleted the move-async-deps-to-direct branch July 22, 2025 19:20
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.

2 participants