Skip to content
Snippets Groups Projects
Unverified Commit ed408eb1 authored by Robert Resch's avatar Robert Resch Committed by GitHub
Browse files

Remove deprecated device tracker constants (#131846)

parent f7d2d06c
No related branches found
No related tags found
No related merge requests found
...@@ -2,15 +2,8 @@ ...@@ -2,15 +2,8 @@
from __future__ import annotations from __future__ import annotations
from functools import partial
from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME # noqa: F401 from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME # noqa: F401
from homeassistant.core import HomeAssistant 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.helpers.typing import ConfigType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
...@@ -23,10 +16,6 @@ from .config_entry import ( # noqa: F401 ...@@ -23,10 +16,6 @@ from .config_entry import ( # noqa: F401
async_unload_entry, async_unload_entry,
) )
from .const import ( # noqa: F401 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_ATTRIBUTES,
ATTR_BATTERY, ATTR_BATTERY,
ATTR_DEV_ID, ATTR_DEV_ID,
...@@ -72,13 +61,3 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: ...@@ -72,13 +61,3 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the device tracker.""" """Set up the device tracker."""
async_setup_legacy_integration(hass, config) async_setup_legacy_integration(hass, config)
return True 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())
...@@ -4,16 +4,9 @@ from __future__ import annotations ...@@ -4,16 +4,9 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from enum import StrEnum from enum import StrEnum
from functools import partial
import logging import logging
from typing import Final 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 from homeassistant.util.signal_type import SignalType
LOGGER: Final = logging.getLogger(__package__) LOGGER: Final = logging.getLogger(__package__)
...@@ -34,19 +27,6 @@ class SourceType(StrEnum): ...@@ -34,19 +27,6 @@ class SourceType(StrEnum):
BLUETOOTH_LE = "bluetooth_le" 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" CONF_SCAN_INTERVAL: Final = "interval_seconds"
SCAN_INTERVAL: Final = timedelta(seconds=12) SCAN_INTERVAL: Final = timedelta(seconds=12)
...@@ -72,10 +52,3 @@ ATTR_IP: Final = "ip" ...@@ -72,10 +52,3 @@ ATTR_IP: Final = "ip"
CONNECTED_DEVICE_REGISTERED = SignalType[dict[str, str | None]]( CONNECTED_DEVICE_REGISTERED = SignalType[dict[str, str | None]](
"device_tracker_connected_device_registered" "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())
...@@ -5,7 +5,6 @@ from datetime import datetime, timedelta ...@@ -5,7 +5,6 @@ from datetime import datetime, timedelta
import json import json
import logging import logging
import os import os
from types import ModuleType
from unittest.mock import call, patch from unittest.mock import call, patch
import pytest import pytest
...@@ -37,8 +36,6 @@ from .common import MockScanner, mock_legacy_device_tracker_setup ...@@ -37,8 +36,6 @@ from .common import MockScanner, mock_legacy_device_tracker_setup
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
async_fire_time_changed, async_fire_time_changed,
help_test_all,
import_and_test_deprecated_constant_enum,
mock_registry, mock_registry,
mock_restore_cache, mock_restore_cache,
patch_yaml_files, patch_yaml_files,
...@@ -739,28 +736,3 @@ def test_see_schema_allowing_ios_calls() -> None: ...@@ -739,28 +736,3 @@ def test_see_schema_allowing_ios_calls() -> None:
"hostname": "beer", "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"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment