Skip to content

fix: warn on nonexistent trigger-source channels, skip disabled-check query when warnings are off - #179

Merged
little-did-I-know merged 1 commit into
mainfrom
investigate/trigger-disabled-warning
Oct 4, 2026
Merged

little-did-I-know merged 1 commit into
mainfrom
investigate/trigger-disabled-warning

Conversation

@little-did-I-know

Copy link
Copy Markdown
Owner

Summary

Follow-up from the code review on #178: two latent issues in the warns_on_disabled_trigger_channel mechanism added by #176.

  • Trigger._warn_if_unreliable_source's disabled-channel check computed disabled = ch is not None and not ch.enabled. A channel number beyond the connected model's num_channels makes get_channel() return None, so disabled evaluates to False and no warning fires — silently indistinguishable from "channel exists and is enabled." Dormant today because the only model with warns_on_disabled_trigger_channel set (SDS824X HD) is 4-channel and matches C1-C4 exactly, but latent for any future narrower model with the same flag.
  • Added a new check that warns whenever the selected channel number exceeds cap.num_channels, independent of warns_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.
  • Separately, the existing disabled-channel check (which does call Channel.enabled, a live SCPI query) is now skipped entirely when this logger's level is above WARNING, so suppressing the warning also skips its round-trip cost — real cost on hardware already profiled as slow.

Test plan

  • New tests: 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_disabled
  • pytest 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 passed
  • pytest -m "not slow" -n 8 — 3015+ passed, no regressions
  • CHANGELOG.md / docs/about/changelog.md mirror verified in sync

… 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

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@little-did-I-know
little-did-I-know merged commit e252a04 into main Oct 4, 2026
30 checks passed
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