Skip to content

Commit 6e567ce

Browse files
authored
Wrap hassio import in is_hassio check in get_system_info helper (#167111)
1 parent e1c1e9a commit 6e567ce

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

homeassistant/helpers/system_info.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from getpass import getuser
77
import logging
88
import platform
9-
from typing import TYPE_CHECKING, Any
9+
from typing import Any
1010

1111
from homeassistant.const import __version__ as current_version
1212
from homeassistant.core import HomeAssistant
@@ -15,7 +15,6 @@
1515
from homeassistant.util.system_info import is_official_image
1616

1717
from .hassio import is_hassio
18-
from .importlib import async_import_module
1918
from .singleton import singleton
2019

2120
_LOGGER = logging.getLogger(__name__)
@@ -54,15 +53,6 @@ def _read_arch_file() -> str:
5453
@bind_hass
5554
async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]:
5655
"""Return info about the system."""
57-
# Local import to avoid circular dependencies
58-
# We use the import helper because hassio
59-
# may not be loaded yet and we don't want to
60-
# do blocking I/O in the event loop to import it.
61-
if TYPE_CHECKING:
62-
from homeassistant.components import hassio # noqa: PLC0415
63-
else:
64-
hassio = await async_import_module(hass, "homeassistant.components.hassio")
65-
6656
is_hassio_ = is_hassio(hass)
6757

6858
info_object = {
@@ -105,6 +95,9 @@ async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]:
10595

10696
# Enrich with Supervisor information
10797
if is_hassio_:
98+
# Local import to avoid circular dependencies
99+
from homeassistant.components import hassio # noqa: PLC0415
100+
108101
if not (info := hassio.get_info(hass)):
109102
_LOGGER.warning("No Home Assistant Supervisor info available")
110103
info = {}

0 commit comments

Comments
 (0)