docs: Add REQUEST scope demos to FastAPI and Flask examples#476
Merged
docs: Add REQUEST scope demos to FastAPI and Flask examples#476
Conversation
Update example applications to demonstrate Scope.REQUEST usage with a RequestContext service and /context endpoint. Update READMEs with request scoping sections showing lifecycle and usage patterns.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #476 +/- ##
=======================================
Coverage 91.85% 91.85%
=======================================
Files 21 21
Lines 1903 1903
Branches 372 372
=======================================
Hits 1748 1748
Misses 91 91
Partials 64 64
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This was referenced Feb 7, 2026
mikelane
added a commit
that referenced
this pull request
Feb 7, 2026
## Summary - Adds explicit warning to CLAUDE.md Tool Usage section: never use bare `python`/`python3`, always use `uv run python` - Documents the `lights-on-uv.sh` AYLO hook that enforces this at the decision boundary Bare `python` resolves to system Python which has a stale dioxide install missing recent features (e.g., `Scope.REQUEST`, `profile` param). This caused a false positive during PR #476 review. ## Test plan - [x] Documentation-only change, no code affected - [x] Pre-commit hooks pass Fixes #480 Generated with [Claude Code](https://claude.ai/claude-code) Co-authored-by: Claude Opus 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
RequestContextservice withScope.REQUESTto both FastAPI and Flask example apps/contextendpoint demonstrating per-request unique IDs via request scopingContext
The middleware integration for request scoping (issue #339) is already fully implemented in
python/dioxide/fastapi.pyandpython/dioxide/flask.pywith 40 passing integration tests. The remaining gap was that example applications did not demonstrateScope.REQUESTusage. This PR fills that gap.The production code includes:
DioxideMiddleware(FastAPI): ASGI middleware creatingScopedContainerper requestconfigure_dioxide()(Flask): Sets upbefore_request/teardown_requesthooks for scope lifecycleInject()andinject(): Resolve from the request scope automaticallyScopedContainer: Caches REQUEST-scoped instances per scope, disposes lifecycle components on exitTest plan
ruff check)ruff format --check)Fixes #339
Generated with Claude Code