Replace index-based discovery with ScraperRegistry (#554)#572
Replace index-based discovery with ScraperRegistry (#554)#572danieldotnl merged 2 commits intomasterfrom
Conversation
Replace fragile array-index lookups (SCRAPER_IDX/PLATFORM_IDX) with a type-safe ScraperRegistry using deterministic string IDs derived from config names. This makes scraper/entity lookup reload-safe since order no longer matters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add _deduplicate_id() for scraper names that collide (appends _2, _3, etc.) - Add _deduplicate_entity_key() for entity names that collide within a scraper - Use enumerate index for unnamed scrapers without a resource URL - Add proper TYPE_CHECKING type hints for ScraperInstance fields - Add contains() method to ScraperRegistry - Add tests for duplicate scraper names and duplicate entity names Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis pull request replaces index-based scraper discovery with a type-safe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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 unit tests (beta)
📝 Coding Plan
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 |
Summary
SCRAPER_IDX/PLATFORM_IDX) with a type-safeScraperRegistryusing deterministic string IDs derived from config names_2,_3suffixes and a warning logChanges
registry.py—ScraperInstancedataclass andScraperRegistryclass__init__.py— uses registry instead of dict-of-lists; discovery passes string IDsconst.py— removedSCRAPER_IDX/PLATFORM_IDX/SCRAPER_DATA, addedSCRAPER_ID/ENTITY_KEYtest_registry.py— unit tests for registry operationstest_init.py— updated for registry-based lookups, added duplicate-name testssensor.py,binary_sensor.py,button.py(they pass discovery_info through without inspecting it)Test plan
Closes #554
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Improvements