refactor: Extract startup() into 8 named submethods#1951
Open
cl445 wants to merge 1 commit intoKartoffelToby:developfrom
Open
refactor: Extract startup() into 8 named submethods#1951cl445 wants to merge 1 commit intoKartoffelToby:developfrom
cl445 wants to merge 1 commit intoKartoffelToby:developfrom
Conversation
Break the monolithic startup() (~888 lines) into a slim orchestrator (~22 lines) and 8 focused private methods: - _check_entities_ready(sensor_state) -> bool - _collect_trv_states() -> list[State] - _resolve_temperature_range(states) - _initialize_sensors(sensor_state) - _restore_state(states) [async] - _validate_hvac_mode(states) - _initialize_trvs() [async] - _finalize_startup() [async] All methods use strict type annotations (State, list[State], etc.). Eliminates the ContinueLoop exception anti-pattern. Fixes type inconsistencies found during extraction: - _current_humidity: int(0) -> float(0.0), matching property return type - bt_min_temp/bt_max_temp: int -> float, matching reduce_attribute output - Explicit casts for attributes.get() restores (bool, float, str) - Redundant convert_to_float on already-float value removed Adds 37 unit tests in tests/unit/test_climate_startup.py covering submethods 1-6. Full suite: 911 passed.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
startup()(~888 lines) into a slim orchestrator (~22 lines) and 8 focused private methods with strict type annotationsContinueLoopexception anti-pattern_current_humidity,bt_min_temp/bt_max_temp, attribute restore casts)Changes
New orchestrator (
startup())8 extracted submethods
_check_entities_ready(sensor_state: State | None) -> bool_collect_trv_states() -> list[State]_resolve_temperature_range(states: list[State])_initialize_sensors(sensor_state: State | None)_restore_state(states: list[State])async_get_last_state_validate_hvac_mode(states: list[State])_initialize_trvs()_finalize_startup()Type fixes
_current_humidity:0(int) →0.0: float— matchescurrent_humidityproperty return typebt_min_temp/bt_max_temp:0/30(int) →0.0/30.0: float— matchesreduce_attribute()outputbool(),float(),str()casts onattributes.get()restoresconvert_to_float()on already-float valueTest plan
tests/unit/test_climate_startup.pycovering submethods 1–6