Skip to content

v1.12.0 — Narrow exception handling, refactor library internals

Choose a tag to compare

@kayloehmann kayloehmann released this 19 Apr 18:13

Summary

Medium-severity review follow-ups. Pure refactor + error-handling-hygiene release — no UI-visible behaviour change, but unexpected failures now surface as real errors instead of being silently swallowed.

Integration

Exception handling narrowed

Replaced broad except Exception catch-alls in critical paths with precise type tuples:

  • base_coordinator (WS connect, stale WS disconnect, token revoke on shutdown) → (aiohttp.ClientError, TimeoutError, OSError)
  • mqtt_bridge (state + availability publish) → HomeAssistantError
  • coordinator._async_handle_mqtt_commandHomeAssistantError + GardenaException
  • config_flow → mapped domain types via lookup tables, _LOGGER.exception for everything else

ConfigFlow error mapping extracted

Three separate if/elif ladders mapping GardenaAuthenticationError / GardenaForbiddenError / GardenaRateLimitError / GardenaConnectionError to translation keys are now a single dict[type[Exception], str] (_GARDENA_ERROR_MAP at module level; local map for Automower because its exception types are lazy-imported). Adding a new mapped exception is now a one-line change.

aiogardenasmart 0.1.8 → 0.1.9

Three matching micro-refactors in the pinned dependency:

  • Header cacheGardenaClient caches the static parts of the request header (Authorization-Provider, X-Api-Key, Accept, Content-Type) once in __init__; only Authorization is rebuilt per request.
  • setdefault_parse_devices collapses six if not in: devices[x] = ... patterns into a single dict.setdefault.
  • Dispatch tableGardenaWebSocket._apply_service_update replaces a five-branch if/elif cascade with _SINGLETON_SERVICES: dict[ServiceType, tuple[attr_name, service_cls]]. Adding a new singleton service is a one-line change.

Also cleared two pre-existing mypy warnings (models._attr_timestamp now returns properly typed str | None; stale # type: ignore[unreachable] in auth.py removed).

Test status

  • 591 integration tests pass
  • 104 library tests pass
  • ruff check, ruff format --check, mypy --strict all clean

🤖 Generated with Claude Code