Add option for lazy JinjaTemplateSource creation to JinjaTemplates - #117
Conversation
📝 WalkthroughWalkthroughChangesLazy Jinja template sources
Repository metadata updates
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant TemplateCaller
participant JinjaTemplates
participant SourceFactory
participant JinjaTemplateSource
TemplateCaller->>JinjaTemplates: Access source or request template
JinjaTemplates->>SourceFactory: Create source on first access
SourceFactory->>JinjaTemplateSource: Construct source
JinjaTemplates->>JinjaTemplateSource: Get named template
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_jinja.py (1)
24-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert deferred, one-time construction explicitly.
These cases would still pass if the factory were invoked in
__init__or rebuilt on every access. Add a counted factory test that asserts zero calls after construction, one call after the first access, and still one call after subsequent accesses or renders.Also applies to: 37-40
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_jinja.py` around lines 24 - 34, Add counted-factory tests for both lazy template instances, asserting the factory has zero calls immediately after construction, exactly one after the first template access, and remains at one across subsequent accesses and renders. Use a mutable counter or equivalent around the Environment factory while preserving the existing async and sync behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_jinja.py`:
- Around line 24-34: Add counted-factory tests for both lazy template instances,
asserting the factory has zero calls immediately after construction, exactly one
after the first template access, and remains at one across subsequent accesses
and renders. Use a mutable counter or equivalent around the Environment factory
while preserving the existing async and sync behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a4303d63-6ee1-430b-af65-631158809890
📒 Files selected for processing (5)
.gitignore.ignorehtmy/__init__.pyhtmy/jinja.pytests/test_jinja.py
Summary by CodeRabbit
New Features
Bug Fixes
Chores