♻️ Extract _try_fetch helper to collapse try/except duplication #47

Merged
mat merged 1 commit from refactor/try-fetch-helper into main 2026-07-10 18:01:19 +00:00
Owner

Pure, behavior-preserving refactor of coordinator.py.

Collapses the 4 repeated try/except ComwattAuthError: raise / except Exception: <fallback> blocks (site time-series, device power, device energy, switch refresh) into a single _try_fetch(fn, *args) helper that re-raises auth errors and returns None on any other failure. Call sites guard with is not None / or {}.

  • 32/32 tests pass, ruff clean.
  • Part of a 5-PR simplification pass (1 PR per point).
Pure, behavior-preserving refactor of `coordinator.py`. Collapses the 4 repeated `try/except ComwattAuthError: raise / except Exception: <fallback>` blocks (site time-series, device power, device energy, switch refresh) into a single `_try_fetch(fn, *args)` helper that re-raises auth errors and returns `None` on any other failure. Call sites guard with `is not None` / `or {}`. - 32/32 tests pass, ruff clean. - Part of a 5-PR simplification pass (1 PR per point).
♻️ Extract _try_fetch helper to collapse try/except duplication
All checks were successful
Validate / lint-ruff (push) Successful in 7s
Validate / test-pytest (push) Successful in 2m59s
Validate / type-check-mypy (push) Successful in 3m7s
Validate / lint-ruff (pull_request) Successful in 7s
Validate / test-pytest (pull_request) Successful in 3m0s
Validate / type-check-mypy (pull_request) Successful in 3m7s
a33571367a
mat merged commit 867cd51e74 into main 2026-07-10 18:01:19 +00:00
mat deleted branch refactor/try-fetch-helper 2026-07-10 18:01:20 +00:00
mat referenced this pull request from a commit 2026-07-10 18:06:30 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mat/homeassistant-comwatt!47
No description provided.