Skip to content

refactor(zwave_js): hoist push event handlers to private methods - #1244

Merged
raman325 merged 1 commit into
mainfrom
refactor/zwave-js-push-handler-methods
Jun 11, 2026
Merged

refactor(zwave_js): hoist push event handlers to private methods#1244
raman325 merged 1 commit into
mainfrom
refactor/zwave-js-push-handler-methods

Conversation

@raman325

Copy link
Copy Markdown
Owner

Proposed change

The `on_credential_changed` and `on_credential_deleted` closures inside `setup_push_subscription` captured `self` implicitly via lexical scope. Hoist them to bound private methods (`self._on_credential_changed`, `self._on_credential_deleted`) so:

  1. The handler surface is explicit in the class layout (visible to type checkers and to `grep`).
  2. They match how the Matter provider already structures its push handlers (`_handle_lock_operation`, `_handle_lock_user_change`, `_dispatch_lock_user_change`).
  3. Future test mocking / introspection can patch them by name rather than monkey-patching the parent method.

Pure refactor — handler bodies are identical, `@callback` decorator preserved. The `setup_push_subscription` body now wires the bound methods directly into `self.node.on(...)` registrations.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Test plan

  • All 76 existing zwave_js provider tests pass without modification
  • Full suite passes locally

🤖 Generated with Claude Code

The on_credential_changed and on_credential_deleted closures inside
setup_push_subscription captured ``self`` implicitly via lexical
scope. Hoisting them to private bound methods (self._on_credential_changed
and self._on_credential_deleted) makes the handler surface explicit
in the class layout, lets the methods participate in pyright/mypy
attribute checks, and matches how the matter provider already
structures its push handlers (_handle_lock_operation,
_handle_lock_user_change, _dispatch_lock_user_change).

Pure refactor -- handler bodies are identical, ``@callback`` decorator
preserved. setup_push_subscription now wires the bound methods into
self.node.on(...) registrations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 3c3130d50c41
Copilot AI review requested due to automatic review settings June 11, 2026 01:00
@github-actions github-actions Bot added python Pull requests that update Python code code-quality Pull requests that improve code quality labels Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Z-Wave JS provider’s push subscription setup by hoisting inline credential event-handler closures into explicit private instance methods, aligning handler structure with other providers and making the handlers easier to locate, type-check, and mock in tests.

Changes:

  • Replaces the on_credential_changed / on_credential_deleted inner @callback closures with bound methods self._on_credential_changed / self._on_credential_deleted.
  • Keeps handler logic and @callback behavior the same while simplifying setup_push_subscription() wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@raman325
raman325 merged commit 38295e4 into main Jun 11, 2026
14 checks passed
@raman325
raman325 deleted the refactor/zwave-js-push-handler-methods branch June 11, 2026 01:02
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.98%. Comparing base (465678c) to head (dd2b141).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1244   +/-   ##
=======================================
  Coverage   96.98%   96.98%           
=======================================
  Files          53       53           
  Lines        6168     6168           
  Branches      461      461           
=======================================
  Hits         5982     5982           
  Misses        186      186           
Flag Coverage Δ
python 97.52% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...components/lock_code_manager/providers/zwave_js.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality Pull requests that improve code quality python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants