Bundle Ruff for Python codegen formatting#166
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3338920c38
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const GENERATED_FILENAME: &str = "generated.py"; | ||
|
|
||
| pub fn format_python_code(code: &str) -> Result<String> { | ||
| let mut formatter = RuffWasmFormatter::new()?; |
There was a problem hiding this comment.
Reuse the bundled formatter across generated files
For package/directory generation, render_python_file is called once per module plus support files, but each call reaches this function and recompiles/instantiates the 4 MB Ruff Wasm module (and re-hashes it) from scratch. Schemas with many namespaces will therefore pay the full Wasm startup cost hundreds of times during one codegen -l python -f run; keep one formatter/module for the generation pass or cache the compiled module so formatting scales with file count rather than repeated Wasm compilation.
Useful? React with 👍 / 👎.
|
📖 Documentation Preview: https://reflectapi-docs-preview-pr-166.partly.workers.dev Updated automatically from commit aa1dee1 |
Summary
Validation
Notes