You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop the coordinator's private copy of hass (P3-2)
DataUpdateCoordinator.__init__ already assigns self.hass, so `self._hass =
hass` left every coordinator carrying two names for one object. They cannot
diverge - the same hass is assigned and then handed to super() a few lines
later - which is why this sat at P3 rather than higher.
Worth removing anyway. The underscore claimed an ownership this code does not
have: hass belongs to Home Assistant, which exposes it publicly and reads it
in its own methods. While hass stays a plain attribute the two are identical;
if it ever became a property, the private copy would quietly bypass whatever
that property did. views.py and config_flow.py already use self.hass, so the
coordinator was also the odd one out inside this repo.
Both reads happen long after construction, and nothing before super() touches
self.hass, so there is no ordering hazard.
Seven tests reached the attribute through coordinator._hass. Confirmed they
actually exercise it by making the source change first: all seven failed with
AttributeError before being retargeted, so the rename is tested rather than
assumed. Two new tests pin the base class's hass as the one it was given and
refuse the private copy coming back.
361 tests, ruff clean, mypy clean against Home Assistant 2026.2.3.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LLPEGFSy3fLEuXNUPAPWR4
0 commit comments