Skip to content

feat(deps): make FastAPI/Uvicorn/JinjaX optional extras (0.3.0b0)#7

Merged
fsecada01 merged 4 commits intomasterfrom
001-optional-deps
Feb 23, 2026
Merged

feat(deps): make FastAPI/Uvicorn/JinjaX optional extras (0.3.0b0)#7
fsecada01 merged 4 commits intomasterfrom
001-optional-deps

Conversation

@fsecada01
Copy link
Copy Markdown
Owner

Summary

  • Closes Make FastAPI/JinjaX optional dependencies; add Flask and Litestar adapter stubs #4 — FastAPI, Uvicorn, and JinjaX are no longer mandatory dependencies. pydantic is now the only hard runtime requirement.
  • Adds [fastapi], [dev-base], and [all] optional extras groups; [dev] self-references via component-framework[dev-base,fastapi,django,websockets].
  • Adds _require_extra() helper in adapters/__init__.py — all 9 adapter modules now raise a clear, actionable ImportError when their extras group is missing.
  • Adds pytest.importorskip guards to 10 adapter test files so they skip cleanly in isolated installs.
  • Adds 13 new tests in tests/test_optional_extras.py covering the guard helper and each adapter family.
  • Updates CI to an extras isolation matrix (base / fastapi / django / all) × Python 3.11–3.14.
  • Adds CHANGELOG.md with breaking change documentation and migration instructions.
  • Updates README.md: Adapter Support table, Installation section, Migrating from 0.2.x guide.
  • Creates tracking issues for missing adapters: Flask (Add Flask adapter #5), Litestar (Add Litestar adapter #6).

Breaking Change

fastapi, uvicorn, and jinjax are no longer installed by default.

# Before (0.2.x)
pip install component-framework

# After (0.3.0+)
pip install "component-framework[fastapi]"

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 pass
  • Full suite: 355 passed, 2 pre-existing failures (registry isolation in test_permissions.py, confirmed present before this PR)
  • ruff format --check — clean
  • ruff check — clean
  • ty check src/ — 1 pre-existing warning in testing.py, no new errors
  • CI extras isolation matrix will run on merge (base / fastapi / django / all × Python 3.11–3.14)

🤖 Generated with Claude Code

fsecada01 and others added 4 commits February 23, 2026 00:29
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>
@fsecada01 fsecada01 merged commit aa10ed0 into master Feb 23, 2026
6 checks passed
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.

Make FastAPI/JinjaX optional dependencies; add Flask and Litestar adapter stubs

1 participant