Skip to content

Align PwrUSB power strip with consolidated *Capability architecture#116

Merged
dccote merged 1 commit into
masterfrom
pwrusb-capability-reconcile
Jul 22, 2026
Merged

Align PwrUSB power strip with consolidated *Capability architecture#116
dccote merged 1 commit into
masterfrom
pwrusb-capability-reconcile

Conversation

@dccote

@dccote dccote commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #115. That branch was cut before master consolidated all capability mixins into hardwarelibrary/capabilities.py and renamed them *Control -> *Capability. The merge was clean but left the power-strip family on the old convention, inconsistent with the rest of the library.

Changes

  • Move the three power-strip mixins into the shared hardwarelibrary/capabilities.py as OutletSwitchingCapability, DefaultOutletCapability, CurrentMeteringCapability (canonical Capability base).
  • Delete hardwarelibrary/powerstrips/capabilities.py.
  • Reduce PowerStripDevice to a pure marker (like LaserSourceDevice); capabilities() / hasCapability() come from PhysicalDevice.
  • Update pwrusb.py bases/imports, the package __init__ re-export, testPwrUSB.py, the pyhardwarelibrary skill, and the CHANGELOG entry.

Why it mattered

Before this, PwrUSBDevice's mixins subclassed a different Capability base than the canonical one, so isinstance(dev, hardwarelibrary.capabilities.OutletSwitchingCapability) found nothing and capabilities() returned the old *Control names. Now introspection is uniform:

capabilities(): ['OutletSwitchingCapability', 'DefaultOutletCapability', 'CurrentMeteringCapability']
all subclass canonical Capability? True

Testing

python3 -m pytest hardwarelibrary/tests/testPwrUSB.py — 14 passed, 3 hardware-skipped. Full suite: no new failures vs. the master baseline.

🤖 Generated with Claude Code

Problem: The PwrUSB family (PR #115) was branched before master consolidated all
capability mixins into hardwarelibrary/capabilities.py and renamed them
*Control -> *Capability. The clean merge left the power strip on the old
convention: a separate hardwarelibrary/powerstrips/capabilities.py with its own
Capability base and OutletSwitchingControl/DefaultOutletControl/
CurrentMeteringControl names, plus a duplicate capabilities()/hasCapability() on
PowerStripDevice. It imported and passed tests but was inconsistent with the
rest of the library, and mixins subclassed a different Capability base than the
canonical one (so isinstance against hardwarelibrary.capabilities found nothing).

Solution: Move the three mixins into the shared hardwarelibrary/capabilities.py
as OutletSwitchingCapability, DefaultOutletCapability, and
CurrentMeteringCapability (canonical Capability base); delete
powerstrips/capabilities.py. Reduce PowerStripDevice to a pure marker like
LaserSourceDevice, inheriting capabilities()/hasCapability() from
PhysicalDevice. Update pwrusb.py bases/imports, the package __init__ re-export,
tests, the skill doc, and the CHANGELOG entry accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dccote
dccote merged commit f64341a into master Jul 22, 2026
14 checks passed
@dccote
dccote deleted the pwrusb-capability-reconcile branch July 22, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant