fix(tools): StubProbe missing capabilities property breaks pyocd list --targets --pack=... (closes #1959)#1986
Open
seam0814 wants to merge 1 commit into
Open
Conversation
…ist --targets --pack=...` (closes pyocd#1959) `DebugProbe.capabilities` is declared as an abstract property that raises `NotImplementedError` in the base class. `StubProbe` — instantiated by `ListGenerator.list_targets()` whenever a CMSIS-Pack file is passed via `--pack=...` so that targets can be enumerated without a real probe — did not override it. The result was that any invocation of pyocd list --targets --pack=<any_pack_file> failed silently with a stripped error line and no traceback: 0000626 C Error: [__main__] making the failure essentially undiagnosable for the user. Reported in pyocd#1959 with root cause already pinpointed. Override the property on `StubProbe` to return an empty `set()`: @Property def capabilities(self): return set() An empty set is the truthful stub value — the placeholder probe has no real features — and matches the expected `Set[Capability]` type declared by the base class, so any downstream `Capability.X in probe.capabilities` membership check now behaves as "probe lacks every feature" rather than crashing. Added `test/unit/test_stub_probe.py` with two regression cases: * `capabilities` returns `set()` (the contract this PR establishes) * the returned value is iterable + membership-testable so downstream consumers don't change behaviour Full unit test suite: 1097 passed, 41 skipped. Co-Authored-By: Claude Opus 4.7 <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
`DebugProbe.capabilities` is declared as an abstract property that
raises `NotImplementedError` in the base class. `StubProbe` —
instantiated by `ListGenerator.list_targets()` whenever a CMSIS-Pack
file is passed via `--pack=...` so that targets can be enumerated
without a real probe — did not override it.
The result is that any invocation of
```
pyocd list --targets --pack=<any_pack_file>
```
fails silently with a stripped error line and no traceback:
```
0000626 C Error: [main]
```
making the failure essentially undiagnosable. Reported in #1959 with
the root cause already pinpointed.
Closes #1959.
Change
```diff
class StubProbe(DebugProbe):
@Property
def unique_id(self) -> str:
return "0"
+
```
An empty set is the truthful stub value — the placeholder probe has
no real features — and matches the expected `Set[Capability]` type
declared by the base class, so any downstream
`Capability.X in probe.capabilities` membership check now behaves as
"probe lacks every feature" rather than crashing.
Test
Added `test/unit/test_stub_probe.py` with two regression cases:
consumers don't change behaviour
```
$ python -m pytest test/unit/
1097 passed, 41 skipped in 1.87s
```
Scope
Two-file change. No public API change. `StubProbe` is only used
internally by `ListGenerator` for offline pack inspection; no
behavioural change to real probes (`CMSISDAPv1Probe`,
`CMSISDAPv2Probe`, `JLinkProbe`, etc.) all of which already provide
their own `capabilities`.