fix: parent/child lock sync resolution#604
Conversation
tykeal
left a comment
There was a problem hiding this comment.
Thanks for the contribution! The problem you've identified is real — CONF_PARENT stores the entry title but the resolution only compared against CONF_LOCK_NAME, so parent/child relationships could silently fail to resolve. The fix approach is sound.
However, there are several items that need to be addressed before this can be merged:
CI Failures
Lint (ruff format): custom_components/keymaster/__init__.py needs reformatting. The project uses ruff format for code formatting.
Recommendation: Install pre-commit in your local dev environment. The repo has a .pre-commit-config.yaml that will catch formatting and linting issues before they reach CI:
pip install pre-commit
pre-commit installThis will automatically run ruff format, ruff check, and other hooks on every commit so you don't have to manually track these.
Pytest failures: 12 tests are failing with "Lingering timer" errors — likely related to the update=True change on add_lock() causing timer lifecycle issues during setup/reload. See the line comment for details.
Missing Test Coverage
This project enforces 100% patch coverage via Codecov. All new/changed lines must be covered by tests. Currently this PR has no test changes — you'll need to add tests covering:
- Parent resolution matching against
entry.title(the new path) - The
setup_dataflow ensuring resolvedCONF_PARENT_ENTRY_IDis used consistently - The
_rebuild_lock_relationshipspriority change (explicit ID before name fallback) - The
update=Truebehavior onadd_lock
See tests/test_init.py and tests/test_coordinator.py for existing patterns.
tykeal
left a comment
There was a problem hiding this comment.
Line-level comments on specific areas of concern.
|
@ps851112 Please see my comments above. I would strongly encourage you to rebase onto the latest main to pick up several linting fixes that have recently been merged. |
ed8abc7 to
7aa1be2
Compare
CI Status UpdateCI has run and Prek (pre-commit) is failing with a mypy error: This blocks Pytest and Coverage from running, so we can't verify the tests pass yet. It looks like commit assert call_args is not Noneor use Recommendation: Install prek or pre-commit locally so you can catch these issues before pushing. The project's Additionally, all 3 review threads from the previous review are still unresolved with no responses. I've posted follow-up comments on each. Even if you believe the code changes address the concerns, please respond to the threads so we can have a productive discussion and move toward resolution. Thanks! |
- Make add_lock(update=...) conditional on existing lock presence, preserving fresh-setup vs reload semantics. - In relationship rebuild, fall back to name matching when parent_config_entry_id is set but stale (entry deleted/unloaded). - Remove redundant setup_data alias; use config_entry.data directly. - Fix mypy union-attr narrowing in tests/test_init.py. - Add test_rebuild_falls_back_to_name_when_parent_entry_stale. Co-authored-by: paul.sayre <paul.sayre@outlook.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
60398a1 to
222e445
Compare
|
Pushed updates to address all outstanding review feedback (maintainer push to contributor branch). Summary:
Local validation is passing ( |
|
Reopening to re-trigger CI on the new commit. |
|
Seems github needs some coffee today. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #604 +/- ##
==========================================
+ Coverage 84.14% 88.38% +4.24%
==========================================
Files 10 39 +29
Lines 801 3892 +3091
Branches 0 30 +30
==========================================
+ Hits 674 3440 +2766
- Misses 127 452 +325
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes child-lock sync not propagating from the parent lock due to parent relationship resolution/runtime linkage issues.
Root Cause
Changes
Validation