Avoid late import of area registry in device registry if its not used (#111081)

pull/111102/head
J. Nick Koston 2024-02-21 12:45:00 -06:00 committed by GitHub
parent 395a452162
commit 7bf0fb9e48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -654,10 +654,6 @@ class DeviceRegistry:
via_device_id: str | None | UndefinedType = UNDEFINED, via_device_id: str | None | UndefinedType = UNDEFINED,
) -> DeviceEntry | None: ) -> DeviceEntry | None:
"""Update device attributes.""" """Update device attributes."""
# Circular dep
# pylint: disable-next=import-outside-toplevel
from . import area_registry as ar
old = self.devices[device_id] old = self.devices[device_id]
new_values: dict[str, Any] = {} # Dict with new key/value pairs new_values: dict[str, Any] = {} # Dict with new key/value pairs
@ -688,6 +684,10 @@ class DeviceRegistry:
and area_id is UNDEFINED and area_id is UNDEFINED
and old.area_id is None and old.area_id is None
): ):
# Circular dep
# pylint: disable-next=import-outside-toplevel
from . import area_registry as ar
area = ar.async_get(self.hass).async_get_or_create(suggested_area) area = ar.async_get(self.hass).async_get_or_create(suggested_area)
area_id = area.id area_id = area.id