Commit cc230dd
Define validateReady only on PhysicalDevice
Problem: validateReady was defined twice, as a no-op on Capability and for
real on PhysicalDevice, with the MRO picking the right one. The no-op was
never reached by any driver in the library -- PhysicalDevice sits at MRO
index 2 and Capability at index 10, so it was shadowed everywhere it
mattered. It only ran for a capability mixed into something that is not a
device, and there it silently skipped the check. That also put a device
lifecycle concept in capabilities.py, which has no business defining one.
Solution: drop the fallback and keep the single definition on PhysicalDevice,
where the state machine lives; capabilities.py only calls it. Anything
hosting a capability without being a PhysicalDevice now has to answer for
readiness itself, which is the honest contract: every capability's docstring
already says to combine it with a PhysicalDevice.
The three test stubs that stand in for a device -- _RecordingAnalogDevice and
_FailingAnalogDevice, and _MinimalLockIn in testSR830 -- supply it, as they
already supply the hooks. The trade-off is the failure mode for a capability
mixed into a non-device: previously no validation at all, now an
AttributeError naming validateReady.
Note that delegating from Capability.validateReady to PhysicalDevice's would
not have worked: it is unreachable from any driver, and on a bare mixin it
raises AttributeError on the missing state attribute.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 238648c commit cc230dd
5 files changed
Lines changed: 21 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 121 | | |
129 | 122 | | |
130 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| |||
327 | 331 | | |
328 | 332 | | |
329 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
330 | 338 | | |
331 | 339 | | |
332 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
0 commit comments