fix: has_outdoor_temperature must return bool, not raw JSON value - #222
Draft
bluetoothbot wants to merge 1 commit into
Draft
fix: has_outdoor_temperature must return bool, not raw JSON value#222bluetoothbot wants to merge 1 commit into
bluetoothbot wants to merge 1 commit into
Conversation
has_outdoor_temperature returned the raw thermostat_json value (or None when the key is absent), violating its declared -> bool return type. Every sibling capability predicate (has_relative_humidity, has_emergency_heat, etc.) wraps the lookup in bool(); this one did not. Since py.typed shipped (hvaclibs#203), the annotation is a downstream contract, so a None return where False is expected is a real type-accuracy defect. Wrap the lookup in bool() to match the siblings and the annotation.
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.
What:
NexiaThermostat.has_outdoor_temperature()now returns a realbool.Why: It returned the raw
thermostat_jsonvalue — orNonewhen the key is absent — despite its-> boolannotation. Every sibling capability predicate (has_relative_humidity,has_emergency_heat,has_variable_fan_speed,has_zones,has_dehumidify_support,has_humidify_support,has_air_cleaner) wraps the lookup inbool(); this one was the lone outlier. Since the PEP 561py.typedmarker shipped (#203), the annotation is a downstream contract, so aNonereturn whereFalseis expected is a genuine type-accuracy defect — same class as the int→float setpoint series (#205/#206).How: Wrap the lookup in
bool(...)to match the siblings and the annotation. One-line change.Testing: Added
test_has_outdoor_temperature_returns_boolassertingis False/is Truefor absent,True, andFalseJSON. The test fails on the old code (None is False) and passes with the fix. Full suite: 58 passed, 1 skipped; ruff clean.Quality Report
Changes: 2 files changed, 20 insertions(+), 1 deletion(-)
Code scan: clean
Tests: passed (58 passed)
Branch hygiene: clean
Generated by Kōan