Repository navigation
Split the Python app entry template into one file per framework - #472
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
| {{/if}} | ||
|
|
||
| {{#if (eq observability "sentry")}} | ||
| from app.observability import init_sentry |
There was a problem hiding this comment.
The new Flask template imports init_sentry when Sentry is selected, but never uses it. The repository requires: “Emit helpers, imports, and variables only when the selected branch uses them.” Django and Litestar have the same unused import, and the pattern appears in the other non-FastAPI templates too.
Remove the unused imports or wire them into the intended startup code. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The Python app entry template was one 1,667-line
main.py.hbsthat held every web framework. Its FastAPI branch alone ran from line 39 to line 1128. This PR splits it into one file per framework underpython-base/src/app/main/, the same layout as the Rust split in #471.fastapi.py.hbsdjango.py.hbsflask.py.hbslitestar.py.hbsstarlette.py.hbsaiohttp.py.hbsnone.py.hbsstreamlit.py.hbsNone of the new files checks
pythonWebFramework. To add a framework, you add one file.The Python handler picks
main/<framework>.py.hbs(falling back tonone.py.hbs), writes it tosrc/app/main.pyand skips the other files.How the files were made
A script fixed
pythonWebFrameworkto each value and removed every branch that value decides. Conditions that mixed the framework with another field keep only the other field's part. For example,(and (eq pythonWebFramework "litestar") (or ...auth...))becomes the auth check inlitestar.py.hbsand disappears from the other files. No code was edited by hand.Verification
main.pyrenders the same, byte for byte, from the old template and the new files across 3,136 configurations. That covers all 8 frameworks, each with every value of every Python field set one at a time, plus 300 random combinations. A one-character change toflask.py.hbsmade all 392 Flask configurations fail, so the check does catch differences.src/app/main.pyand nomain/directory.The Go
main.go.hbsstays as it is. Split the same way, gin and echo would differ by only 72 of about 570 lines, and go-zero, kratos and httprouter would be identical files. That much duplicated code would be harder to maintain than the conditionals.Summary by CodeRabbit
The split appears to preserve behavior, but the unused-import rule must be satisfied before merging.
Findings
Reviews (2) · Last reviewed commit: "Merge branch 'main' into refactor/split-..." · Reviewed by Greptile