Skip to content

[codex] add framework component quickstarts - #161

Merged
lbliii merged 7 commits into
mainfrom
codex/test-framework-adapters
Jul 7, 2026
Merged

[codex] add framework component quickstarts#161
lbliii merged 7 commits into
mainfrom
codex/test-framework-adapters

Conversation

@lbliii

@lbliii lbliii commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • test Kida against Flask 3.1.3, Django 6.0.6, FastAPI 0.139.0, and Starlette 1.3.1 on free-threaded Python 3.14
  • add runnable Flask, Django, and FastAPI examples with a typed form component, full-page route, named fragment route, and XSS escaping smoke assertion
  • replace stale integration docs with ten-minute framework-first quickstarts: explicit Python 3.14 floor, one-line uv add, form + fragment, and prominent Jinja2 {% set %} scoping migration link
  • route the Tutorials landing page to horizontal framework adopters first
  • retain dependency-free adapter doubles while adding real-framework contracts and CI-run subprocess examples

Why

The adapter APIs already shipped, but their docs advertised stale names, current framework releases were not exercised in CI, and users had to assemble component and fragment patterns themselves. These changes make the existing-framework path a tested first-class entry point.

Impact

Kida's runtime contract remains dependency-free: [project].dependencies = []. Flask, Django, FastAPI, Starlette, HTTPX, and Uvicorn are locked only in the development group for compatibility tests and examples. No adapter signature or render behavior changes.

Contract parity

Contract API/CLI Programmatic Protocol Schema/Types Docs Examples Tests
Flask typed component + fragment unchanged init_kida, render_template, render_block HTML form POST typed def quickstart runnable app real Flask client + subprocess
Django typed component + fragment unchanged backend render, backend.env.render_block HTML form POST + CSRF guide typed def quickstart runnable app real EngineHandler/client + subprocess
FastAPI/Starlette component + fragment unchanged TemplateResponse, render_block ASGI + URL-encoded POST typed def quickstart runnable app real Request/HTMLResponse/ASGI + subprocess

Validation

  • make lint
  • make format-check
  • make ty
  • full coverage suite: 4,290 passed, 5 skipped; 84.53% coverage
  • no-GIL safety suite: 131 passed with PYTHON_GIL=0
  • focused framework/docs/examples suite: 26 passed
  • all three guide Kida snippets compile
  • make docs completed; Bengal reported the existing 23 internal-link health findings across 8 unrelated pages
  • make package-smoke passed for wheel and sdist
  • uv lock --check --offline
  • runtime dependency assertion confirms dependencies = []

Steward Notes

  • Consulted scoped guidance: root constitution, Documentation Site, Examples, and Test Corpus stewards.
  • Risks: optional integration packages must never become runtime dependencies; guide snippets and runnable examples must agree; request-local render state must remain unchanged.
  • Evidence: locked current framework versions, real request clients, isolated-process example smoke tests, escaping assertions, guide-contract regression test, docs build, full suite, and no-GIL suite.
  • Collateral: docs landing page, all three guides, examples index, lockfile, and CI test inventory move together.
  • Unresolved tradeoffs: none.

Closes #137.
Closes #156.

@lbliii lbliii changed the title [codex] cover framework adapter contracts [codex] add framework component quickstarts Jul 7, 2026
@lbliii
lbliii marked this pull request as ready for review July 7, 2026 14:33
Copilot AI review requested due to automatic review settings July 7, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR makes Kida’s optional framework adapters (Flask/Django/Starlette/FastAPI) a first-class, CI-exercised onboarding path by adding current-version integration quickstarts, runnable examples, and contract tests—while keeping Kida’s runtime dependency set empty.

Changes:

  • Added dev-only framework dependency locks plus adapter contract tests (including “imports without optional frameworks” coverage).
  • Added runnable, smoke-tested framework examples (Flask/Django/FastAPI) demonstrating typed components + full-page + fragment rendering with XSS-escaping assertions.
  • Replaced/reshaped integration docs into “ten-minute” framework-first quickstarts and updated tutorial landing/README references to match the real adapter APIs.

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Locks new dev-only framework dependencies (Flask/Django/FastAPI/Starlette/Uvicorn/etc.) for CI compatibility coverage.
pyproject.toml Adds optional framework packages to the dev dependency group (explicitly dev-only).
README.md Updates integration snippets to the current contrib API names (init_kida, KidaTemplates, KidaTemplates backend).
tests/test_examples.py Adds subprocess smoke tests for framework examples without starting servers.
tests/test_docs_install_snippets.py Adds a contract test to keep framework quickstarts consistent (Python 3.14 floor + uv install + migration link + fragment path).
tests/contrib/test_framework_adapters.py New contract tests for contrib adapters (import boundary, Flask helper wiring, Django backend behavior, Starlette response/metadata contract).
src/kida/contrib/__init__.py Fixes stale contrib package docs to reference real adapter entry points (no re-exports).
src/kida/contrib/flask.py Updates documentation to reflect “does not replace Flask’s Jinja env” positioning.
src/kida/contrib/starlette.py Clarifies TemplateResponse() is synchronous and documents the async/streaming path.
site/content/docs/tutorials/_index.md Reorders Tutorials landing to lead with framework quickstarts.
site/content/docs/tutorials/flask-integration.md Replaces stale integration doc with a 10-minute typed-component + fragment quickstart.
site/content/docs/tutorials/django-integration.md Replaces stale integration doc with a 10-minute backend + fragment quickstart.
site/content/docs/tutorials/starlette-integration.md Replaces stale Starlette/FastAPI doc with a FastAPI-first quickstart + Starlette notes + async/streaming guidance.
examples/README.md Lists the new runnable framework examples and updates install/run snippets to uv.
examples/flask_components/app.py New runnable Flask example with --smoke path + XSS escaping assertion + fragment rendering.
examples/flask_components/README.md Run/smoke instructions for the Flask example.
examples/flask_components/templates/components.html Typed component template used by the Flask example (form + preview fragment).
examples/django_components/app.py New runnable Django example with --smoke path + fragment rendering + XSS escaping assertion.
examples/django_components/README.md Run/smoke instructions for the Django example.
examples/django_components/templates/components.html Typed component template used by the Django example.
examples/fastapi_components/app.py New runnable FastAPI example with ASGI-client smoke path + fragment rendering + XSS escaping assertion.
examples/fastapi_components/README.md Run/smoke instructions for the FastAPI example.
examples/fastapi_components/templates/components.html Typed component template used by the FastAPI example.
examples/fastapi_async/app.py Updates the “not installed” message to uv add ... wording.
examples/fastapi_async/README.md Updates install/test commands to use uv and clarifies Python 3.14+.
examples/fastapi_async/test_fastapi_async.py Switches example tests to HTTPX ASGI transport + async pytest style.
changelog.d/156.added.md Changelog entry for the new guides and smoke-tested examples.

Comment thread src/kida/contrib/flask.py
Comment thread src/kida/contrib/starlette.py
Comment thread src/kida/contrib/flask.py Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 14:48
@lbliii
lbliii merged commit 10c4097 into main Jul 7, 2026
11 checks passed
@lbliii
lbliii deleted the codex/test-framework-adapters branch July 7, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.

Comment thread tests/test_examples.py
Comment on lines +79 to +87
example_dir = EXAMPLES_DIR / example
result = subprocess.run(
[sys.executable, "app.py", "--smoke"],
cwd=example_dir,
capture_output=True,
text=True,
timeout=30,
check=False,
)
Comment thread tests/test_examples.py
Comment on lines 8 to 12
import importlib
import subprocess
import sys
from pathlib import Path

Comment on lines +46 to +52
result = subprocess.run(
[sys.executable, "-c", script],
capture_output=True,
text=True,
timeout=30,
check=False,
)
Comment on lines +9 to +13
import subprocess
import sys
from pathlib import Path
from types import ModuleType, SimpleNamespace
from typing import TYPE_CHECKING, cast
Comment thread README.md
Comment on lines 305 to +308
```python
# Flask
from kida.contrib.flask import KidaFlask
kida = KidaFlask(app)
from kida.contrib.flask import init_kida, render_template
kida_env = init_kida(app)
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.

Epic: Horizontal integration guides — Flask, Django, FastAPI Bring framework adapters under real test coverage and fix stale contrib docs

2 participants