feat(deps): make FastAPI/Uvicorn/JinjaX optional extras (0.3.0b0)#7
Merged
feat(deps): make FastAPI/Uvicorn/JinjaX optional extras (0.3.0b0)#7
Conversation
Closes #4. Resolves the forced FastAPI dependency for Django and base users. Breaking change: fastapi, uvicorn, and jinjax are no longer installed by default. Install with `pip install 'component-framework[fastapi]'`. Changes: - pyproject.toml: pydantic is now the only mandatory dependency; fastapi, uvicorn, jinjax moved to [fastapi] optional extra; added dev-base, all extras; dev self-references via component-framework[dev-base,...] - adapters/__init__.py: _require_extra() helper returns actionable ImportError - 9 adapter modules: ImportError guards with install hints via _require_extra - 10 test files: pytest.importorskip guards for adapter-specific skipping - tests/test_optional_extras.py: 13 new tests covering guard behavior - .github/workflows/ci.yml: extras isolation matrix (base/fastapi/django/all) - CHANGELOG.md: documents breaking change and migration path - README.md: Adapter Support table, Migration from 0.2.x section - Tracking issues: Flask adapter #5, Litestar adapter #6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tests/conftest.py imports django at module level, so the extras isolation matrix immediately fails with ModuleNotFoundError on base/fastapi variants. Replace the matrix with a single pip install -e ".[dev]" that provides all adapters, matching how tests are run locally. Also clean up lint job to use .[dev] instead of .[dev,django,websockets] since dev already self-references all runtime extras. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_reload_adapter evicted adapter modules from sys.modules to force a re-import during the ImportError guard tests. After the test it did nothing (original bug) or re-imported (creating a new module object), leaving sys.modules in an inconsistent state. Subsequent tests hold class references (e.g. AuthenticatedComponentView) bound to the original module's globals at collection time. Monkeypatch fixtures also patch the original module. A new module object breaks both, causing 404s in test_permissions tests that run after test_optional_extras. Fix: save original adapter sys.modules entries before eviction and restore them exactly after the failed import, ensuring all tests share the same module objects throughout the session. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
pydanticis now the only hard runtime requirement.[fastapi],[dev-base], and[all]optional extras groups;[dev]self-references viacomponent-framework[dev-base,fastapi,django,websockets]._require_extra()helper inadapters/__init__.py— all 9 adapter modules now raise a clear, actionableImportErrorwhen their extras group is missing.pytest.importorskipguards to 10 adapter test files so they skip cleanly in isolated installs.tests/test_optional_extras.pycovering the guard helper and each adapter family.base/fastapi/django/all) × Python 3.11–3.14.CHANGELOG.mdwith breaking change documentation and migration instructions.README.md: Adapter Support table, Installation section, Migrating from 0.2.x guide.Breaking Change
fastapi,uvicorn, andjinjaxare no longer installed by default.Existing FastAPI users must update their install command. CI pipelines installing the bare package will break.
Test plan
tests/test_optional_extras.py— 13 new tests, all passtest_permissions.py, confirmed present before this PR)ruff format --check— cleanruff check— cleanty check src/— 1 pre-existing warning intesting.py, no new errors🤖 Generated with Claude Code