diff --git a/homeassistant/loader.py b/homeassistant/loader.py index a4f1a862c45..089a0b522fa 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -35,11 +35,16 @@ from .generated.usb import USB from .generated.zeroconf import HOMEKIT, ZEROCONF from .util.json import JSON_DECODE_EXCEPTIONS, json_loads -# Typing imports that create a circular dependency if TYPE_CHECKING: + from functools import cached_property + + # The relative imports below are guarded by TYPE_CHECKING + # because they would cause a circular import otherwise. from .config_entries import ConfigEntry from .helpers import device_registry as dr from .helpers.typing import ConfigType +else: + from .backports.functools import cached_property _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) @@ -650,12 +655,12 @@ class Integration: _LOGGER.info("Loaded %s from %s", self.domain, pkg_path) - @property + @cached_property def name(self) -> str: """Return name.""" return self.manifest["name"] - @property + @cached_property def disabled(self) -> str | None: """Return reason integration is disabled.""" return self.manifest.get("disabled") @@ -710,7 +715,7 @@ class Integration: """Return the integration IoT Class.""" return self.manifest.get("iot_class") - @property + @cached_property def integration_type( self, ) -> Literal["entity", "device", "hardware", "helper", "hub", "service", "system"]: