Add pylint rule for cached_property (#127482)
This commit is contained in:
parent
1dd59375f6
commit
6eb49991a4
3 changed files with 9 additions and 5 deletions
|
@ -9,6 +9,7 @@ import it.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
# pylint: disable-next=hass-deprecated-import
|
||||||
from functools import cached_property as _cached_property, partial
|
from functools import cached_property as _cached_property, partial
|
||||||
|
|
||||||
from homeassistant.helpers.deprecation import (
|
from homeassistant.helpers.deprecation import (
|
||||||
|
|
|
@ -19,6 +19,12 @@ class ObsoleteImportMatch:
|
||||||
|
|
||||||
|
|
||||||
_OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
|
_OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
|
||||||
|
"functools": [
|
||||||
|
ObsoleteImportMatch(
|
||||||
|
reason="replaced by propcache.cached_property",
|
||||||
|
constant=re.compile(r"^cached_property$"),
|
||||||
|
),
|
||||||
|
],
|
||||||
"homeassistant.backports.enum": [
|
"homeassistant.backports.enum": [
|
||||||
ObsoleteImportMatch(
|
ObsoleteImportMatch(
|
||||||
reason="We can now use the Python 3.11 provided enum.StrEnum instead",
|
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": [
|
"homeassistant.backports.functools": [
|
||||||
ObsoleteImportMatch(
|
ObsoleteImportMatch(
|
||||||
reason=(
|
reason="replaced by propcache.cached_property",
|
||||||
"We can now use the Python 3.12 provided "
|
|
||||||
"functools.cached_property instead"
|
|
||||||
),
|
|
||||||
constant=re.compile(r"^cached_property$"),
|
constant=re.compile(r"^cached_property$"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from functools import cached_property
|
from functools import cached_property # pylint: disable=hass-deprecated-import
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue