From ed408eb1a10ff93f15984b6cd9e378b32c5da18b Mon Sep 17 00:00:00 2001
From: Robert Resch <robert@resch.dev>
Date: Thu, 28 Nov 2024 16:54:23 +0100
Subject: [PATCH] Remove deprecated device tracker constants (#131846)

---
 .../components/device_tracker/__init__.py     | 21 --------------
 .../components/device_tracker/const.py        | 27 ------------------
 tests/components/device_tracker/test_init.py  | 28 -------------------
 3 files changed, 76 deletions(-)

diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py
index 28991483cda..313373e3181 100644
--- a/homeassistant/components/device_tracker/__init__.py
+++ b/homeassistant/components/device_tracker/__init__.py
@@ -2,15 +2,8 @@
 
 from __future__ import annotations
 
-from functools import partial
-
 from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME  # noqa: F401
 from homeassistant.core import HomeAssistant
-from homeassistant.helpers.deprecation import (
-    all_with_deprecated_constants,
-    check_if_deprecated_constant,
-    dir_with_deprecated_constants,
-)
 from homeassistant.helpers.typing import ConfigType
 from homeassistant.loader import bind_hass
 
@@ -23,10 +16,6 @@ from .config_entry import (  # noqa: F401
     async_unload_entry,
 )
 from .const import (  # noqa: F401
-    _DEPRECATED_SOURCE_TYPE_BLUETOOTH,
-    _DEPRECATED_SOURCE_TYPE_BLUETOOTH_LE,
-    _DEPRECATED_SOURCE_TYPE_GPS,
-    _DEPRECATED_SOURCE_TYPE_ROUTER,
     ATTR_ATTRIBUTES,
     ATTR_BATTERY,
     ATTR_DEV_ID,
@@ -72,13 +61,3 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
     """Set up the device tracker."""
     async_setup_legacy_integration(hass, config)
     return True
-
-
-# As we import deprecated constants from the const module, we need to add these two functions
-# otherwise this module will be logged for using deprecated constants and not the custom component
-# 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/homeassistant/components/device_tracker/const.py b/homeassistant/components/device_tracker/const.py
index 964b7faab9b..c9e4d4e910a 100644
--- a/homeassistant/components/device_tracker/const.py
+++ b/homeassistant/components/device_tracker/const.py
@@ -4,16 +4,9 @@ from __future__ import annotations
 
 from datetime import timedelta
 from enum import StrEnum
-from functools import partial
 import logging
 from typing import Final
 
-from homeassistant.helpers.deprecation import (
-    DeprecatedConstantEnum,
-    all_with_deprecated_constants,
-    check_if_deprecated_constant,
-    dir_with_deprecated_constants,
-)
 from homeassistant.util.signal_type import SignalType
 
 LOGGER: Final = logging.getLogger(__package__)
@@ -34,19 +27,6 @@ class SourceType(StrEnum):
     BLUETOOTH_LE = "bluetooth_le"
 
 
-# SOURCE_TYPE_* below are deprecated as of 2022.9
-# use the SourceType enum instead.
-_DEPRECATED_SOURCE_TYPE_GPS: Final = DeprecatedConstantEnum(SourceType.GPS, "2025.1")
-_DEPRECATED_SOURCE_TYPE_ROUTER: Final = DeprecatedConstantEnum(
-    SourceType.ROUTER, "2025.1"
-)
-_DEPRECATED_SOURCE_TYPE_BLUETOOTH: Final = DeprecatedConstantEnum(
-    SourceType.BLUETOOTH, "2025.1"
-)
-_DEPRECATED_SOURCE_TYPE_BLUETOOTH_LE: Final = DeprecatedConstantEnum(
-    SourceType.BLUETOOTH_LE, "2025.1"
-)
-
 CONF_SCAN_INTERVAL: Final = "interval_seconds"
 SCAN_INTERVAL: Final = timedelta(seconds=12)
 
@@ -72,10 +52,3 @@ ATTR_IP: Final = "ip"
 CONNECTED_DEVICE_REGISTERED = SignalType[dict[str, str | None]](
     "device_tracker_connected_device_registered"
 )
-
-# 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/device_tracker/test_init.py b/tests/components/device_tracker/test_init.py
index 362258b035a..e73c18919c5 100644
--- a/tests/components/device_tracker/test_init.py
+++ b/tests/components/device_tracker/test_init.py
@@ -5,7 +5,6 @@ from datetime import datetime, timedelta
 import json
 import logging
 import os
-from types import ModuleType
 from unittest.mock import call, patch
 
 import pytest
@@ -37,8 +36,6 @@ from .common import MockScanner, mock_legacy_device_tracker_setup
 from tests.common import (
     assert_setup_component,
     async_fire_time_changed,
-    help_test_all,
-    import_and_test_deprecated_constant_enum,
     mock_registry,
     mock_restore_cache,
     patch_yaml_files,
@@ -739,28 +736,3 @@ def test_see_schema_allowing_ios_calls() -> None:
             "hostname": "beer",
         }
     )
-
-
-@pytest.mark.parametrize(
-    "module",
-    [device_tracker, device_tracker.const],
-)
-def test_all(module: ModuleType) -> None:
-    """Test module.__all__ is correctly set."""
-    help_test_all(module)
-
-
-@pytest.mark.parametrize(("enum"), list(SourceType))
-@pytest.mark.parametrize(
-    "module",
-    [device_tracker, device_tracker.const],
-)
-def test_deprecated_constants(
-    caplog: pytest.LogCaptureFixture,
-    enum: SourceType,
-    module: ModuleType,
-) -> None:
-    """Test deprecated constants."""
-    import_and_test_deprecated_constant_enum(
-        caplog, module, enum, "SOURCE_TYPE_", "2025.1"
-    )
-- 
GitLab