Add type annotations to some hassio API (#83103)
* Add type annotations to some hassio API * Adjust callers
This commit is contained in:
parent
faea29a268
commit
4edebacba5
7 changed files with 15 additions and 15 deletions
|
@ -144,7 +144,7 @@ class Analytics:
|
|||
async def send_analytics(self, _=None) -> None:
|
||||
"""Send analytics."""
|
||||
supervisor_info = None
|
||||
operating_system_info = {}
|
||||
operating_system_info: dict[str, Any] = {}
|
||||
|
||||
if not self.onboarded or not self.preferences.get(ATTR_BASE, False):
|
||||
LOGGER.debug("Nothing to submit")
|
||||
|
@ -156,7 +156,7 @@ class Analytics:
|
|||
|
||||
if self.supervisor:
|
||||
supervisor_info = hassio.get_supervisor_info(self.hass)
|
||||
operating_system_info = hassio.get_os_info(self.hass)
|
||||
operating_system_info = hassio.get_os_info(self.hass) or {}
|
||||
|
||||
system_info = await async_get_system_info(self.hass)
|
||||
integrations = []
|
||||
|
|
|
@ -13,7 +13,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
# The hassio integration has not yet fetched data from the supervisor
|
||||
raise ConfigEntryNotReady
|
||||
|
||||
board: str
|
||||
board: str | None
|
||||
if (board := os_info.get("board")) is None or not board.startswith("odroid"):
|
||||
# Not running on a Hardkernel board, Home Assistant may have been migrated
|
||||
hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
|
||||
|
|
|
@ -21,7 +21,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
"""Return board info."""
|
||||
if (os_info := get_os_info(hass)) is None:
|
||||
raise HomeAssistantError
|
||||
board: str
|
||||
board: str | None
|
||||
if (board := os_info.get("board")) is None:
|
||||
raise HomeAssistantError
|
||||
if not board.startswith("odroid"):
|
||||
|
|
|
@ -241,7 +241,7 @@ HARDWARE_INTEGRATIONS = {
|
|||
|
||||
@callback
|
||||
@bind_hass
|
||||
def get_info(hass):
|
||||
def get_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
||||
"""Return generic information from Supervisor.
|
||||
|
||||
Async friendly.
|
||||
|
@ -251,7 +251,7 @@ def get_info(hass):
|
|||
|
||||
@callback
|
||||
@bind_hass
|
||||
def get_host_info(hass):
|
||||
def get_host_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
||||
"""Return generic host information.
|
||||
|
||||
Async friendly.
|
||||
|
@ -261,7 +261,7 @@ def get_host_info(hass):
|
|||
|
||||
@callback
|
||||
@bind_hass
|
||||
def get_store(hass):
|
||||
def get_store(hass: HomeAssistant) -> dict[str, Any] | None:
|
||||
"""Return store information.
|
||||
|
||||
Async friendly.
|
||||
|
@ -311,7 +311,7 @@ def get_addons_changelogs(hass):
|
|||
|
||||
@callback
|
||||
@bind_hass
|
||||
def get_os_info(hass):
|
||||
def get_os_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
||||
"""Return OS information.
|
||||
|
||||
Async friendly.
|
||||
|
@ -321,7 +321,7 @@ def get_os_info(hass):
|
|||
|
||||
@callback
|
||||
@bind_hass
|
||||
def get_core_info(hass):
|
||||
def get_core_info(hass: HomeAssistant) -> dict[str, Any] | None:
|
||||
"""Return Home Assistant Core information from Supervisor.
|
||||
|
||||
Async friendly.
|
||||
|
@ -723,7 +723,7 @@ class HassioDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
addons_info = get_addons_info(self.hass)
|
||||
addons_stats = get_addons_stats(self.hass)
|
||||
addons_changelogs = get_addons_changelogs(self.hass)
|
||||
store_data = get_store(self.hass)
|
||||
store_data = get_store(self.hass) or {}
|
||||
|
||||
repositories = {
|
||||
repo[ATTR_SLUG]: repo[ATTR_NAME]
|
||||
|
|
|
@ -22,8 +22,8 @@ def async_register(
|
|||
|
||||
async def system_health_info(hass: HomeAssistant):
|
||||
"""Get info for the info page."""
|
||||
info = get_info(hass)
|
||||
host_info = get_host_info(hass)
|
||||
info = get_info(hass) or {}
|
||||
host_info = get_host_info(hass) or {}
|
||||
supervisor_info = get_supervisor_info(hass)
|
||||
|
||||
healthy: bool | dict[str, str]
|
||||
|
@ -57,7 +57,7 @@ async def system_health_info(hass: HomeAssistant):
|
|||
}
|
||||
|
||||
if info.get("hassos") is not None:
|
||||
os_info = get_os_info(hass)
|
||||
os_info = get_os_info(hass) or {}
|
||||
information["board"] = os_info.get("board")
|
||||
|
||||
information["supervisor_api"] = system_health.async_check_can_reach_url(
|
||||
|
|
|
@ -13,7 +13,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
# The hassio integration has not yet fetched data from the supervisor
|
||||
raise ConfigEntryNotReady
|
||||
|
||||
board: str
|
||||
board: str | None
|
||||
if (board := os_info.get("board")) is None or not board.startswith("rpi"):
|
||||
# Not running on a Raspberry Pi, Home Assistant may have been migrated
|
||||
hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
|
||||
|
|
|
@ -36,7 +36,7 @@ def async_info(hass: HomeAssistant) -> list[HardwareInfo]:
|
|||
"""Return board info."""
|
||||
if (os_info := get_os_info(hass)) is None:
|
||||
raise HomeAssistantError
|
||||
board: str
|
||||
board: str | None
|
||||
if (board := os_info.get("board")) is None:
|
||||
raise HomeAssistantError
|
||||
if not board.startswith("rpi"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue