Repository navigation
fix: warn on nonexistent trigger-source channels, skip disabled-check query when warnings are off - #179
Merged
Conversation
… query when warnings are off Trigger._warn_if_unreliable_source's disabled-channel check computed disabled = ch is not None and not ch.enabled, so a channel number beyond the model's num_channels (get_channel() returns None) silently passed as "not disabled". Dormant today (SDS824X HD, the only flagged model, is 4-channel and matches C1-C4 exactly) but latent for any future narrower model with the same flag. Adds a channel-existence check driven by cap.num_channels directly (no live query, no hardware-behavior claim, applies to every model regardless of warns_on_disabled_trigger_channel), and gates the existing disabled-channel check (which does call Channel.enabled, a live query) behind logger.isEnabledFor(WARNING) so suppressing the warning also skips its round-trip cost.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 from the code review on #178: two latent issues in the
warns_on_disabled_trigger_channelmechanism added by #176.Trigger._warn_if_unreliable_source's disabled-channel check computeddisabled = ch is not None and not ch.enabled. A channel number beyond the connected model'snum_channelsmakesget_channel()returnNone, sodisabledevaluates toFalseand no warning fires — silently indistinguishable from "channel exists and is enabled." Dormant today because the only model withwarns_on_disabled_trigger_channelset (SDS824X HD) is 4-channel and matchesC1-C4exactly, but latent for any future narrower model with the same flag.cap.num_channels, independent ofwarns_on_disabled_trigger_channel— it's a fact from the model's own channel count, not a measured hardware quirk, so it needs no live query and applies to every model. The warning message deliberately does not claim "no error is queued" (unlike the measured SDS824X HD quirks above it) since how an unmeasured model actually responds to an out-of-range source hasn't been verified.Channel.enabled, a live SCPI query) is now skipped entirely when this logger's level is aboveWARNING, so suppressing the warning also skips its round-trip cost — real cost on hardware already profiled as slow.Test plan
test_channel_beyond_model_capacity_warns,test_channel_within_model_capacity_does_not_warn,test_flagged_model_with_fewer_channels_still_warns_on_nonexistent_channel(regression test for the exact latent gap),test_disabled_channel_check_skipped_when_warning_disabledpytest tests/test_trigger_coercion_warnings.py tests/test_trigger_comprehensive.py tests/test_trigger_api.py tests/test_trigger_level_sources.py tests/test_vocabulary_matrix.py tests/test_vocabulary.py tests/test_vendor_scope_ops.py— 159 passedpytest -m "not slow" -n 8— 3015+ passed, no regressionsCHANGELOG.md/docs/about/changelog.mdmirror verified in sync