Align PwrUSB power strip with consolidated *Capability architecture#116
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #115. That branch was cut before
masterconsolidated all capability mixins intohardwarelibrary/capabilities.pyand 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
hardwarelibrary/capabilities.pyasOutletSwitchingCapability,DefaultOutletCapability,CurrentMeteringCapability(canonicalCapabilitybase).hardwarelibrary/powerstrips/capabilities.py.PowerStripDeviceto a pure marker (likeLaserSourceDevice);capabilities()/hasCapability()come fromPhysicalDevice.pwrusb.pybases/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 differentCapabilitybase than the canonical one, soisinstance(dev, hardwarelibrary.capabilities.OutletSwitchingCapability)found nothing andcapabilities()returned the old*Controlnames. Now introspection is uniform: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