From 43d0d582efa3ce70aff4517a5792a4e64407d69b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:45:38 +0100 Subject: [PATCH] Cleanup deprecated hassio constants and functions (#158802) --- homeassistant/components/hassio/__init__.py | 45 ------------- tests/components/bluetooth/conftest.py | 4 +- tests/components/hassio/test_init.py | 75 +-------------------- tests/helpers/test_network.py | 2 +- tests/helpers/test_system_info.py | 2 +- 5 files changed, 6 insertions(+), 122 deletions(-) diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index ae72546a10d..a1f30276d1f 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -5,7 +5,6 @@ from __future__ import annotations import asyncio from contextlib import suppress from datetime import datetime -from functools import partial import logging import os import re @@ -42,24 +41,9 @@ from homeassistant.helpers import ( issue_registry as ir, ) from homeassistant.helpers.aiohttp_client import async_get_clientsession -from homeassistant.helpers.deprecation import ( - DeprecatedConstant, - all_with_deprecated_constants, - check_if_deprecated_constant, - deprecated_function, - dir_with_deprecated_constants, -) from homeassistant.helpers.event import async_call_later -from homeassistant.helpers.hassio import ( - get_supervisor_ip as _get_supervisor_ip, - is_hassio as _is_hassio, -) from homeassistant.helpers.issue_registry import IssueSeverity -from homeassistant.helpers.service_info.hassio import ( - HassioServiceInfo as _HassioServiceInfo, -) from homeassistant.helpers.typing import ConfigType -from homeassistant.loader import bind_hass from homeassistant.util.async_ import create_eager_task from homeassistant.util.dt import now @@ -134,14 +118,6 @@ from .websocket_api import async_load_websocket_api _LOGGER = logging.getLogger(__name__) -get_supervisor_ip = deprecated_function( - "homeassistant.helpers.hassio.get_supervisor_ip", breaks_in_ha_version="2025.11" -)(_get_supervisor_ip) -_DEPRECATED_HassioServiceInfo = DeprecatedConstant( - _HassioServiceInfo, - "homeassistant.helpers.service_info.hassio.HassioServiceInfo", - "2025.11", -) # If new platforms are added, be sure to import them above # so we do not make other components that depend on hassio @@ -302,19 +278,6 @@ def hostname_from_addon_slug(addon_slug: str) -> str: return addon_slug.replace("_", "-") -@callback -@deprecated_function( - "homeassistant.helpers.hassio.is_hassio", breaks_in_ha_version="2025.11" -) -@bind_hass -def is_hassio(hass: HomeAssistant) -> bool: - """Return true if Hass.io is loaded. - - Async friendly. - """ - return _is_hassio(hass) - - async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901 """Set up the Hass.io component.""" # Check local setup @@ -628,11 +591,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data.pop(ADDONS_COORDINATOR, None) return unload_ok - - -# These can be removed if no deprecated constant are in this module anymore -__getattr__ = partial(check_if_deprecated_constant, module_globals=globals()) -__dir__ = partial( - dir_with_deprecated_constants, module_globals_keys=[*globals().keys()] -) -__all__ = all_with_deprecated_constants(globals()) diff --git a/tests/components/bluetooth/conftest.py b/tests/components/bluetooth/conftest.py index 20468d23dc9..2641f6b6dcd 100644 --- a/tests/components/bluetooth/conftest.py +++ b/tests/components/bluetooth/conftest.py @@ -45,7 +45,7 @@ def disable_bluetooth_auto_recovery(): def mock_operating_system_85(): """Mock running Home Assistant Operating system 8.5.""" with ( - patch("homeassistant.components.hassio.is_hassio", return_value=True), + patch("homeassistant.helpers.hassio.is_hassio", return_value=True), patch( "homeassistant.components.hassio.get_os_info", return_value={ @@ -67,7 +67,7 @@ def mock_operating_system_85(): def mock_operating_system_90(): """Mock running Home Assistant Operating system 9.0.""" with ( - patch("homeassistant.components.hassio.is_hassio", return_value=True), + patch("homeassistant.helpers.hassio.is_hassio", return_value=True), patch( "homeassistant.components.hassio.get_os_info", return_value={ diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index b4a23202f9d..8008d5ae5f4 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -1,7 +1,6 @@ """The tests for the hassio component.""" from datetime import timedelta -import logging import os from typing import Any from unittest.mock import AsyncMock, patch @@ -13,15 +12,13 @@ import pytest from voluptuous import Invalid from homeassistant.auth.const import GROUP_ID_ADMIN -from homeassistant.components import frontend, hassio +from homeassistant.components import frontend from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.components.hassio import ( ADDONS_COORDINATOR, DOMAIN, get_core_info, - get_supervisor_ip, hostname_from_addon_slug, - is_hassio as deprecated_is_hassio, ) from homeassistant.components.hassio.config import STORAGE_KEY from homeassistant.components.hassio.const import ( @@ -32,15 +29,10 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, issue_registry as ir from homeassistant.helpers.hassio import is_hassio -from homeassistant.helpers.service_info.hassio import HassioServiceInfo from homeassistant.setup import async_setup_component from homeassistant.util import dt as dt_util -from tests.common import ( - MockConfigEntry, - async_fire_time_changed, - import_and_test_deprecated_constant, -) +from tests.common import MockConfigEntry, async_fire_time_changed from tests.test_util.aiohttp import AiohttpClientMocker MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @@ -1089,69 +1081,6 @@ def test_hostname_from_addon_slug() -> None: ) -def test_deprecated_function_is_hassio( - hass: HomeAssistant, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test calling deprecated_is_hassio function will create log entry.""" - - deprecated_is_hassio(hass) - assert caplog.record_tuples == [ - ( - "homeassistant.components.hassio", - logging.WARNING, - "The deprecated function is_hassio was called. It will be " - "removed in HA Core 2025.11. Use homeassistant.helpers" - ".hassio.is_hassio instead", - ) - ] - - -def test_deprecated_function_get_supervisor_ip( - hass: HomeAssistant, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test calling get_supervisor_ip function will create log entry.""" - - get_supervisor_ip() - assert caplog.record_tuples == [ - ( - "homeassistant.helpers.hassio", - logging.WARNING, - "The deprecated function get_supervisor_ip was called. It will " - "be removed in HA Core 2025.11. Use homeassistant.helpers" - ".hassio.get_supervisor_ip instead", - ) - ] - - -@pytest.mark.parametrize( - ("constant_name", "replacement_name", "replacement"), - [ - ( - "HassioServiceInfo", - "homeassistant.helpers.service_info.hassio.HassioServiceInfo", - HassioServiceInfo, - ), - ], -) -def test_deprecated_constants( - caplog: pytest.LogCaptureFixture, - constant_name: str, - replacement_name: str, - replacement: Any, -) -> None: - """Test deprecated automation constants.""" - import_and_test_deprecated_constant( - caplog, - hassio, - constant_name, - replacement_name, - replacement, - "2025.11", - ) - - @pytest.mark.parametrize( ("board", "issue_id"), [ diff --git a/tests/helpers/test_network.py b/tests/helpers/test_network.py index 46d84ea768d..a8a16fa6730 100644 --- a/tests/helpers/test_network.py +++ b/tests/helpers/test_network.py @@ -663,7 +663,7 @@ async def test_get_request_host_no_host_header(hass: HomeAssistant) -> None: assert _get_request_host() is None -@patch("homeassistant.components.hassio.is_hassio", Mock(return_value=True)) +@patch("homeassistant.helpers.hassio.is_hassio", Mock(return_value=True)) @patch( "homeassistant.components.hassio.get_host_info", Mock(return_value={"hostname": "homeassistant"}), diff --git a/tests/helpers/test_system_info.py b/tests/helpers/test_system_info.py index ad140834199..a3363c8d60c 100644 --- a/tests/helpers/test_system_info.py +++ b/tests/helpers/test_system_info.py @@ -30,7 +30,7 @@ async def test_get_system_info_supervisor_not_available( patch("platform.system", return_value="Linux"), patch("homeassistant.helpers.system_info.is_docker_env", return_value=True), patch("homeassistant.helpers.system_info.is_official_image", return_value=True), - patch.object(hassio, "is_hassio", return_value=True), + patch("homeassistant.helpers.hassio.is_hassio", return_value=True), patch.object(hassio, "get_info", return_value=None), patch("homeassistant.helpers.system_info.cached_get_user", return_value="root"), ):