Repository navigation
Ignore entity references in Jinja comments - #1322
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new ChangesJinja Comment Stripping in Entity Extraction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Pull request overview
This pull request updates Spook’s template entity reference extraction so that entity-like strings inside Jinja {# ... #} comments are ignored by the regex-based fallback, preventing false positives in unknown-entity repairs.
Changes:
- Strip Jinja comment blocks from template strings before running entity-ID regex scans.
- Add a regression test ensuring entity-like strings inside Jinja comments don’t produce entity references.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
custom_components/spook/entity_filtering.py |
Adds Jinja comment stripping and applies it to the regex entity extraction path to avoid false positives. |
tests/ectoplasms/automation/repairs/test_unknown_entity_references.py |
Adds a test case covering entity-like strings inside Jinja comments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



Description
Spook's regex fallback now strips Jinja comments before scanning templates for entity IDs. Entity-like strings in commented-out template code no longer count as active references.
Motivation and Context
This addresses the Jinja comment false positive reported in #1081. The commented
sensor.toothbrush_change_headexample was still seen by the regex fallback, even though Jinja would ignore it at render time.How has this been tested?
uv run pytest tests/ectoplasms/automation/repairs/test_unknown_entity_references.py::test_value_template_ignores_entity_id_in_jinja_comment -quv run pytest tests/test_entity_filtering.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.py tests/ectoplasms/script/repairs/test_unknown_entity_references.py -quv run ruff check custom_components/spook/entity_filtering.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.pyuv run pylint custom_components/spook/entity_filtering.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.pyScreenshots (if appropriate):
Not applicable.
Types of changes
Checklist