From 7b6df1a8a074afefff6a50b3495dafd5954b6dac Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:04:41 +0100 Subject: [PATCH] Cleanup deprecated typing helpers (#158806) --- homeassistant/helpers/typing.py | 37 --------------------------------- tests/helpers/test_typing.py | 37 --------------------------------- 2 files changed, 74 deletions(-) delete mode 100644 tests/helpers/test_typing.py diff --git a/homeassistant/helpers/typing.py b/homeassistant/helpers/typing.py index dde456bf7bc..9c044c7ea03 100644 --- a/homeassistant/helpers/typing.py +++ b/homeassistant/helpers/typing.py @@ -2,18 +2,10 @@ from collections.abc import Mapping from enum import Enum -from functools import partial from typing import Any, Never import voluptuous as vol -from .deprecation import ( - DeferredDeprecatedAlias, - all_with_deprecated_constants, - check_if_deprecated_constant, - dir_with_deprecated_constants, -) - type GPSType = tuple[float, float] type ConfigType = dict[str, Any] type DiscoveryInfoType = dict[str, Any] @@ -35,32 +27,3 @@ class UndefinedType(Enum): UNDEFINED = UndefinedType._singleton # noqa: SLF001 - - -def _deprecated_typing_helper(attr: str) -> DeferredDeprecatedAlias: - """Help to make a DeferredDeprecatedAlias.""" - - def value_fn() -> Any: - import homeassistant.core # noqa: PLC0415 - - return getattr(homeassistant.core, attr) - - return DeferredDeprecatedAlias(value_fn, f"homeassistant.core.{attr}", "2025.5") - - -# The following types should not used and -# are not present in the core code base. -# They are kept in order not to break custom integrations -# that may rely on them. -# Deprecated as of 2024.5 use types from homeassistant.core instead. -_DEPRECATED_ContextType = _deprecated_typing_helper("Context") -_DEPRECATED_EventType = _deprecated_typing_helper("Event") -_DEPRECATED_HomeAssistantType = _deprecated_typing_helper("HomeAssistant") -_DEPRECATED_ServiceCallType = _deprecated_typing_helper("ServiceCall") - -# 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/helpers/test_typing.py b/tests/helpers/test_typing.py deleted file mode 100644 index 5b50a8864de..00000000000 --- a/tests/helpers/test_typing.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Test typing helper module.""" - -from __future__ import annotations - -from typing import Any - -import pytest - -from homeassistant.core import Context, Event, HomeAssistant, ServiceCall -from homeassistant.helpers import typing as ha_typing - -from tests.common import import_and_test_deprecated_alias - - -@pytest.mark.parametrize( - ("alias_name", "replacement", "breaks_in_ha_version"), - [ - ("ContextType", Context, "2025.5"), - ("EventType", Event, "2025.5"), - ("HomeAssistantType", HomeAssistant, "2025.5"), - ("ServiceCallType", ServiceCall, "2025.5"), - ], -) -def test_deprecated_aliases( - caplog: pytest.LogCaptureFixture, - alias_name: str, - replacement: Any, - breaks_in_ha_version: str, -) -> None: - """Test deprecated aliases.""" - import_and_test_deprecated_alias( - caplog, - ha_typing, - alias_name, - replacement, - breaks_in_ha_version, - )