mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Remove previously deprecated cached_property (#146478)
Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
@ -1,31 +0,0 @@
|
||||
"""Functools backports from standard lib.
|
||||
|
||||
This file contained the backport of the cached_property implementation of Python 3.12.
|
||||
|
||||
Since we have dropped support for Python 3.11, we can remove this backport.
|
||||
This file is kept for now to avoid breaking custom components that might
|
||||
import it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# pylint: disable-next=hass-deprecated-import
|
||||
from functools import cached_property as _cached_property, partial
|
||||
|
||||
from homeassistant.helpers.deprecation import (
|
||||
DeprecatedAlias,
|
||||
all_with_deprecated_constants,
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
|
||||
# cached_property deprecated as of 2024.5 use functools.cached_property instead.
|
||||
_DEPRECATED_cached_property = DeprecatedAlias(
|
||||
_cached_property, "functools.cached_property", "2025.5"
|
||||
)
|
||||
|
||||
__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())
|
@ -25,12 +25,6 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
|
||||
constant=re.compile(r"^cached_property$"),
|
||||
),
|
||||
],
|
||||
"homeassistant.backports.functools": [
|
||||
ObsoleteImportMatch(
|
||||
reason="replaced by propcache.api.cached_property",
|
||||
constant=re.compile(r"^cached_property$"),
|
||||
),
|
||||
],
|
||||
"homeassistant.components.light": [
|
||||
ObsoleteImportMatch(
|
||||
reason="replaced by ColorMode enum",
|
||||
|
@ -1,36 +0,0 @@
|
||||
"""Test backports package."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import cached_property # pylint: disable=hass-deprecated-import
|
||||
from types import ModuleType
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.backports import functools as backports_functools
|
||||
|
||||
from .common import import_and_test_deprecated_alias
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("module", "replacement", "breaks_in_ha_version"),
|
||||
[
|
||||
(backports_functools, cached_property, "2025.5"),
|
||||
],
|
||||
)
|
||||
def test_deprecated_aliases(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
module: ModuleType,
|
||||
replacement: Any,
|
||||
breaks_in_ha_version: str,
|
||||
) -> None:
|
||||
"""Test deprecated aliases."""
|
||||
alias_name = replacement.__name__
|
||||
import_and_test_deprecated_alias(
|
||||
caplog,
|
||||
module,
|
||||
alias_name,
|
||||
replacement,
|
||||
breaks_in_ha_version,
|
||||
)
|
Reference in New Issue
Block a user