Skip to content

v1.8.0 - tenacity + PortalAuth refactor

Choose a tag to compare

@EnO33 EnO33 released this 25 Apr 15:40

Refactor: delegate to libraries, encapsulate state

Two changes that reduce custom plumbing in favour of well-known patterns:

tenacity replaces hand-rolled retry

The retry loop in _http.py is now driven by tenacity.AsyncRetrying (3 attempts, exponential backoff 1s/2s/4s on TimeoutError + aiohttp.ClientError). Same behaviour, delivered by a battle-tested library. tenacity>=8.0 added to manifest requirements; HA core already depends on it.

PortalAuth class encapsulates the 5-step flow

_auth.py is restructured around a single PortalAuth class that owns the (session, timeout, token) state. Each authentication step is now a tiny method instead of a free function repeating (session, timeout, state) parameters. The class also exposes get(path), so the api.py orchestrator no longer needs its own header-building logic.

File-size impact

  • api.py: 146 -> 106 lines (-27%)
  • _http.py: 151 -> 162 lines (+7%, but the retry boilerplate is delegated)
  • _auth.py: 206 -> 217 lines (+5%, but state is now encapsulated and self-documenting)

CI

Aligned on Python 3.13 with pytest-homeassistant-custom-component pinned to its last 3.13-compatible release (0.13.316). Dependabot is configured to ignore bumps that require Python 3.14 until 3.14 wheels stabilise on Linux runners.

Public API

Unchanged. All 23 API tests still pass without modification.