Split util helpers into focused modules#1277
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 PR splits Spook’s broad utility helper module into focused modules for entity filtering, setup forwarding, and sub-integration linking, then updates imports across platform shims and repair modules.
Changes:
- Moves ectoplasm setup forwarding helpers into
setup_helpers.py. - Moves sub-integration symlink helpers into
integration_linking.py. - Updates entity/reference repair modules to import filtering helpers from
entity_filtering.py.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
custom_components/spook/__init__.py |
Uses the new focused helper modules. |
custom_components/spook/entity_filtering.py |
Retains registry, template, and entity filtering helpers after removing unrelated utilities. |
custom_components/spook/setup_helpers.py |
Adds ectoplasm setup forwarding helpers. |
custom_components/spook/integration_linking.py |
Adds sub-integration link/unlink helpers. |
custom_components/spook/binary_sensor.py |
Updates platform forwarding import. |
custom_components/spook/button.py |
Updates platform forwarding import. |
custom_components/spook/event.py |
Updates platform forwarding import. |
custom_components/spook/number.py |
Updates platform forwarding import. |
custom_components/spook/select.py |
Updates platform forwarding import. |
custom_components/spook/sensor.py |
Updates platform forwarding import. |
custom_components/spook/switch.py |
Updates platform forwarding import. |
custom_components/spook/time.py |
Updates platform forwarding import. |
custom_components/spook/repairs.py |
Updates entity ID helper import. |
custom_components/spook/ectoplasms/automation/repairs/unknown_area_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/automation/repairs/unknown_device_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/automation/repairs/unknown_floor_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/automation/repairs/unknown_label_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/automation/repairs/unknown_service_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/group/repairs/unknown_members.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/lovelace/repairs/unknown_entity_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/proximity/repairs/unknown_ignored_zones.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/proximity/repairs/unknown_tracked_entities.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/proximity/repairs/unknown_zone.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/scene/repairs/unknown_entity_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/script/repairs/unknown_area_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/script/repairs/unknown_device_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/script/repairs/unknown_entity_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/script/repairs/unknown_floor_references.py |
Updates filtering helper imports. |
custom_components/spook/ectoplasms/script/repairs/unknown_label_references.py |
Updates filtering helper imports. |
tests/test_util.py |
Updates tests to import helpers from entity_filtering.py. |
pyproject.toml |
Adds a Python 3.13 classifier. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
66b1a36 to
8cd34d2
Compare
18c1807 to
195472f
Compare
util.py had grown to 746 lines mixing three unrelated concerns: registry/ template entity filtering, ectoplasm setup forwarding, and sub-integration symlinking. Split into focused modules and rewired all 30 call sites. Also bump pyproject.toml metadata that drifted from the codebase reality: classifiers no longer list Python 3.11/3.12, requires-python is >=3.13.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25c9474 to
c7e8830
Compare
|



Description
Split
custom_components/spook/util.pyinto three focused modules:entity_filtering.pyfor registry lookups, template entity extraction, comma-separated entity ID handling, and unknown-reference filtering.setup_helpers.pyfor config entry and ectoplasm setup forwarding.integration_linking.pyfor linking and unlinking sub-integrations.The old
util.pymodule is removed and imports are updated to point at the module that owns each concern.Motivation and Context
util.pymixed unrelated helper families in one large module. Splitting it along the existing concern boundaries makes the import graph clearer and reduces the amount of unrelated code a future change has to touch.This PR is stacked on #1276 because that refactor already moves the unknown-reference repair boilerplate out of the leaf modules.
How has this been tested?
uv run pytest -quv run ruff check custom_components/spook testsuv run ruff format --check custom_components/spook testsuv run pylint custom_components/spook tests/test_util.pyScreenshots (if appropriate):
Not applicable.
Types of changes
Checklist