Add pylint rule for cached_property (#127482)

This commit is contained in:
J. Nick Koston 2024-10-03 17:53:55 -05:00 committed by GitHub
parent 1dd59375f6
commit 6eb49991a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@ 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 (

View File

@ -19,6 +19,12 @@ class ObsoleteImportMatch:
_OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
"functools": [
ObsoleteImportMatch(
reason="replaced by propcache.cached_property",
constant=re.compile(r"^cached_property$"),
),
],
"homeassistant.backports.enum": [
ObsoleteImportMatch(
reason="We can now use the Python 3.11 provided enum.StrEnum instead",
@ -27,10 +33,7 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
],
"homeassistant.backports.functools": [
ObsoleteImportMatch(
reason=(
"We can now use the Python 3.12 provided "
"functools.cached_property instead"
),
reason="replaced by propcache.cached_property",
constant=re.compile(r"^cached_property$"),
),
],

View File

@ -3,7 +3,7 @@
from __future__ import annotations
from enum import StrEnum
from functools import cached_property
from functools import cached_property # pylint: disable=hass-deprecated-import
from types import ModuleType
from typing import Any