Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using fast cached_property implementation in propcache #127339

Merged
merged 10 commits into from
Oct 3, 2024
Merged
2 changes: 1 addition & 1 deletion homeassistant/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from __future__ import annotations

from datetime import datetime, timedelta
from functools import cached_property
import secrets
from typing import Any, NamedTuple
import uuid

import attr
from attr import Attribute
from attr.setters import validate
from propcache import cached_property

from homeassistant.const import __version__
from homeassistant.data_entry_flow import FlowResult
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/backports/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

from __future__ import annotations

from functools import cached_property as _cached_property, partial
from functools import partial

from propcache import cached_property as _cached_property

from homeassistant.helpers.deprecation import (
DeprecatedAlias,
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/airgradient/update.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Airgradient Update platform."""

from datetime import timedelta
from functools import cached_property

from propcache import cached_property

from homeassistant.components.update import UpdateDeviceClass, UpdateEntity
from homeassistant.core import HomeAssistant
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/alarm_control_panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from __future__ import annotations

from datetime import timedelta
from functools import cached_property, partial
from functools import partial
import logging
from typing import Any, Final, final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import asyncio
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from functools import cached_property, partial
from functools import partial
import logging
from typing import Any, Protocol, cast

from propcache import cached_property
import voluptuous as vol

from homeassistant.components import websocket_api
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

from datetime import timedelta
from enum import StrEnum
from functools import cached_property, partial
from functools import partial
import logging
from typing import Literal, final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from datetime import timedelta
from enum import StrEnum
from functools import cached_property
import logging
from typing import final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataclasses import asdict
from datetime import datetime, timedelta
from enum import IntFlag
from functools import cached_property, partial
from functools import partial
import logging
import os
from random import SystemRandom
Expand All @@ -18,6 +18,7 @@

from aiohttp import hdrs, web
import attr
from propcache import cached_property
import voluptuous as vol

from homeassistant.components import websocket_api
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/climate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import asyncio
from datetime import timedelta
import functools as ft
from functools import cached_property
import logging
from typing import Any, Literal, final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/cover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from datetime import timedelta
from enum import IntFlag, StrEnum
import functools as ft
from functools import cached_property
import logging
from typing import Any, final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/date/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from __future__ import annotations

from datetime import date, timedelta
from functools import cached_property
import logging
from typing import final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -80,13 +80,13 @@ class DateEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
@final
def device_class(self) -> None:
"""Return the device class for the entity."""
return None
return
bdraco marked this conversation as resolved.
Show resolved Hide resolved

@cached_property
@final
def state_attributes(self) -> None:
"""Return the state attributes."""
return None
return
bdraco marked this conversation as resolved.
Show resolved Hide resolved

@property
@final
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/datetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from __future__ import annotations

from datetime import UTC, datetime, timedelta
from functools import cached_property
import logging
from typing import final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -89,13 +89,13 @@ class DateTimeEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
@final
def device_class(self) -> None:
"""Return entity device class."""
return None
bdraco marked this conversation as resolved.
Show resolved Hide resolved
return

@cached_property
@final
def state_attributes(self) -> None:
"""Return the state attributes."""
return None
return
bdraco marked this conversation as resolved.
Show resolved Hide resolved

@property
@final
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/device_tracker/config_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from __future__ import annotations

import asyncio
from functools import cached_property
from typing import final

from propcache import cached_property

from homeassistant.components import zone
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/device_tracker/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import asyncio
from collections.abc import Callable, Coroutine, Sequence
from datetime import datetime, timedelta
from functools import cached_property
import hashlib
from types import ModuleType
from typing import Any, Final, Protocol, final

import attr
from propcache import cached_property
import voluptuous as vol

from homeassistant import util
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dlna_dms/dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass
from enum import StrEnum
import functools
from functools import cached_property
from typing import Any, cast

from async_upnp_client.aiohttp import AiohttpSessionRequester
Expand All @@ -17,6 +16,7 @@
from async_upnp_client.exceptions import UpnpActionError, UpnpConnectionError, UpnpError
from async_upnp_client.profiles.dlna import ContentDirectoryErrorCode, DmsDevice
from didl_lite import didl_lite
from propcache import cached_property

from homeassistant.components import ssdp
from homeassistant.components.media_player import BrowseError, MediaClass
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/doorbird/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from collections import defaultdict
from dataclasses import dataclass
from functools import cached_property
from http import HTTPStatus
import logging
from typing import Any
Expand All @@ -16,6 +15,7 @@
DoorBirdScheduleEntryOutput,
DoorBirdScheduleEntrySchedule,
)
from propcache import cached_property

from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from dataclasses import asdict, dataclass
from datetime import datetime, timedelta
from enum import StrEnum
from functools import cached_property
import logging
from typing import Any, Self, final

from propcache import cached_property

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from datetime import timedelta
from enum import IntFlag
import functools as ft
from functools import cached_property
import logging
import math
from typing import Any, final

from propcache import cached_property
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ffmpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from __future__ import annotations

import asyncio
from functools import cached_property
import re

from haffmpeg.core import HAFFmpeg
from haffmpeg.tools import IMAGE_JPEG, FFVersion, ImageFrame
from propcache import cached_property
import voluptuous as vol

from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fints/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from collections import namedtuple
from datetime import timedelta
from functools import cached_property
import logging
from typing import Any

from fints.client import FinTS3PinTanClient
from fints.models import SEPAAccount
from propcache import cached_property
import voluptuous as vol

from homeassistant.components.sensor import (
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from __future__ import annotations

from collections.abc import Callable, Iterator
from functools import cached_property, lru_cache, partial
from functools import lru_cache, partial
import logging
import os
import pathlib
from typing import Any, TypedDict

from aiohttp import hdrs, web, web_urldispatcher
import jinja2
from propcache import cached_property
import voluptuous as vol
from yarl import URL

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/geo_location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from __future__ import annotations

from datetime import timedelta
from functools import cached_property
import logging
from typing import Any, final

from propcache import cached_property

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
from homeassistant.core import HomeAssistant
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

from functools import cached_property
import logging
from typing import Any, Final

Expand All @@ -17,6 +16,7 @@
)
from aiohomekit.model.services import Service, ServicesTypes
from aiohomekit.utils import clamp_enum_to_char
from propcache import cached_property

from homeassistant.components.climate import (
ATTR_HVAC_MODE,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from functools import cached_property
from typing import Any

from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import Service, ServicesTypes
from propcache import cached_property

from homeassistant.components.cover import (
ATTR_POSITION,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from functools import cached_property
from typing import Any

from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import Service, ServicesTypes
from propcache import cached_property

from homeassistant.components.fan import (
DIRECTION_FORWARD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from functools import cached_property
from typing import Any

from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import Service, ServicesTypes
from propcache import cached_property

from homeassistant.components.humidifier import (
DEFAULT_MAX_HUMIDITY,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from functools import cached_property
from typing import Any

from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import Service, ServicesTypes
from propcache import cached_property

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
Expand Down
Loading
Loading