Skip to content

Commit

Permalink
Update existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Mar 26, 2024
1 parent 0bdeb39 commit 21567e7
Show file tree
Hide file tree
Showing 61 changed files with 103 additions and 337 deletions.
9 changes: 2 additions & 7 deletions homeassistant/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

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

import attr
Expand All @@ -18,12 +19,6 @@
from . import permissions as perm_mdl
from .const import GROUP_ID_ADMIN

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


TOKEN_TYPE_NORMAL = "normal"
TOKEN_TYPE_SYSTEM = "system"
TOKEN_TYPE_LONG_LIVED_ACCESS_TOKEN = "long_lived_access_token"
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/alarm_control_panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

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

import voluptuous as vol

Expand Down Expand Up @@ -50,11 +50,6 @@
CodeFormat,
)

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

_LOGGER: Final = logging.getLogger(__name__)

SCAN_INTERVAL: Final = timedelta(seconds=30)
Expand Down
10 changes: 2 additions & 8 deletions homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import asyncio
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from functools import partial
from functools import cached_property, partial
import logging
from typing import TYPE_CHECKING, Any, Protocol, cast
from typing import Any, Protocol, cast

import voluptuous as vol

Expand Down Expand Up @@ -112,12 +112,6 @@
from .helpers import async_get_blueprints
from .trace import trace_automation

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


ENTITY_ID_FORMAT = DOMAIN + ".{}"


Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

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

import voluptuous as vol

Expand All @@ -28,11 +28,6 @@
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

_LOGGER = logging.getLogger(__name__)


Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

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

import voluptuous as vol

Expand All @@ -24,11 +25,6 @@

from .const import DOMAIN, SERVICE_PRESS

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

SCAN_INTERVAL = timedelta(seconds=30)

ENTITY_ID_FORMAT = DOMAIN + ".{}"
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from dataclasses import asdict
from datetime import datetime, timedelta
from enum import IntFlag
from functools import partial
from functools import cached_property, partial
import logging
import os
from random import SystemRandom
import time
from typing import TYPE_CHECKING, Any, Final, cast, final
from typing import Any, Final, cast, final

from aiohttp import hdrs, web
import attr
Expand Down Expand Up @@ -85,11 +85,6 @@
from .img_util import scale_jpeg_camera_image
from .prefs import CameraPreferences, DynamicStreamSettings # noqa: F401

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

_LOGGER = logging.getLogger(__name__)

SERVICE_ENABLE_MOTION: Final = "enable_motion_detection"
Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/climate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import asyncio
from datetime import timedelta
import functools as ft
from functools import cached_property
import logging
from typing import TYPE_CHECKING, Any, Literal, final
from typing import Any, Literal, final

import voluptuous as vol

Expand Down Expand Up @@ -115,11 +116,6 @@
HVACMode,
)

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

DEFAULT_MIN_TEMP = 7
DEFAULT_MAX_TEMP = 35
DEFAULT_MIN_HUMIDITY = 30
Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/cover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from datetime import timedelta
from enum import IntFlag, StrEnum
import functools as ft
from functools import cached_property
import logging
from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar, final
from typing import Any, ParamSpec, TypeVar, final

import voluptuous as vol

Expand Down Expand Up @@ -46,11 +47,6 @@

from . import group as group_pre_import # noqa: F401

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

_LOGGER = logging.getLogger(__name__)

DOMAIN = "cover"
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/date/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

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

import voluptuous as vol

Expand All @@ -22,12 +23,6 @@

from .const import DOMAIN, SERVICE_SET_VALUE

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


SCAN_INTERVAL = timedelta(seconds=30)

ENTITY_ID_FORMAT = DOMAIN + ".{}"
Expand Down
8 changes: 2 additions & 6 deletions homeassistant/components/datetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

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

import voluptuous as vol

Expand All @@ -22,11 +23,6 @@

from .const import ATTR_DATETIME, DOMAIN, SERVICE_SET_VALUE

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property

SCAN_INTERVAL = timedelta(seconds=30)

ENTITY_ID_FORMAT = DOMAIN + ".{}"
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,6 +5,7 @@
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
Expand All @@ -13,7 +14,6 @@
import voluptuous as vol

from homeassistant import util
from homeassistant.backports.functools import cached_property
from homeassistant.components import zone
from homeassistant.components.zone import ENTITY_ID_HOME
from homeassistant.config import (
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,6 +7,7 @@
from dataclasses import dataclass
from enum import StrEnum
import functools
from functools import cached_property
from typing import Any, TypeVar, cast

from async_upnp_client.aiohttp import AiohttpSessionRequester
Expand All @@ -17,7 +18,6 @@
from async_upnp_client.profiles.dlna import ContentDirectoryErrorCode, DmsDevice
from didl_lite import didl_lite

from homeassistant.backports.functools import cached_property
from homeassistant.components import ssdp
from homeassistant.components.media_player import BrowseError, MediaClass
from homeassistant.components.media_source.error import Unresolvable
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from dataclasses import asdict, dataclass
from datetime import datetime, timedelta
from enum import StrEnum
from functools import cached_property
import logging
from typing import TYPE_CHECKING, Any, Self, final
from typing import Any, Self, final

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand All @@ -22,12 +23,6 @@

from .const import ATTR_EVENT_TYPE, ATTR_EVENT_TYPES, DOMAIN

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


SCAN_INTERVAL = timedelta(seconds=30)

ENTITY_ID_FORMAT = DOMAIN + ".{}"
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from datetime import timedelta
from enum import IntFlag
import functools as ft
from functools import cached_property
import logging
import math
from typing import TYPE_CHECKING, Any, final
from typing import Any, final

import voluptuous as vol

Expand Down Expand Up @@ -40,12 +41,6 @@
ranged_value_to_percentage,
)

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


_LOGGER = logging.getLogger(__name__)

DOMAIN = "fan"
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/ffmpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

import asyncio
from functools import cached_property
import re
from typing import TYPE_CHECKING, Generic, TypeVar
from typing import Generic, TypeVar

from haffmpeg.core import HAFFmpeg
from haffmpeg.tools import IMAGE_JPEG, FFVersion, ImageFrame
Expand All @@ -28,12 +29,6 @@
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


_HAFFmpegT = TypeVar("_HAFFmpegT", bound=HAFFmpeg)

DOMAIN = "ffmpeg"
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,14 +4,14 @@

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
import voluptuous as vol

from homeassistant.backports.functools import cached_property
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_NAME, CONF_PIN, CONF_URL, CONF_USERNAME
from homeassistant.core import HomeAssistant
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/geo_location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

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

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
Expand All @@ -17,12 +18,6 @@
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType

if TYPE_CHECKING:
from functools import cached_property
else:
from homeassistant.backports.functools import cached_property


_LOGGER = logging.getLogger(__name__)

ATTR_DISTANCE = "distance"
Expand Down
Loading

0 comments on commit 21567e7

Please sign in to comment.