diff --git a/homeassistant/components/alarm_control_panel/reproduce_state.py b/homeassistant/components/alarm_control_panel/reproduce_state.py index 90979d97dd..e7e4c07b8a 100644 --- a/homeassistant/components/alarm_control_panel/reproduce_state.py +++ b/homeassistant/components/alarm_control_panel/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/alert/reproduce_state.py b/homeassistant/components/alert/reproduce_state.py index dfe51df753..9c8cbd1981 100644 --- a/homeassistant/components/alert/reproduce_state.py +++ b/homeassistant/components/alert/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/automation/reproduce_state.py b/homeassistant/components/automation/reproduce_state.py index ff716f3a83..dd2ba824f8 100644 --- a/homeassistant/components/automation/reproduce_state.py +++ b/homeassistant/components/automation/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/blueprint/errors.py b/homeassistant/components/blueprint/errors.py index b422b2dcbe..b5032af932 100644 --- a/homeassistant/components/blueprint/errors.py +++ b/homeassistant/components/blueprint/errors.py @@ -1,5 +1,8 @@ """Blueprint errors.""" -from typing import Any, Iterable +from __future__ import annotations + +from collections.abc import Iterable +from typing import Any import voluptuous as vol from voluptuous.humanize import humanize_error diff --git a/homeassistant/components/climacell/sensor.py b/homeassistant/components/climacell/sensor.py index 3d3006638f..50e051813c 100644 --- a/homeassistant/components/climacell/sensor.py +++ b/homeassistant/components/climacell/sensor.py @@ -2,8 +2,9 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Mapping import logging -from typing import Any, Callable, Mapping +from typing import Any, Callable from pyclimacell.const import CURRENT diff --git a/homeassistant/components/climacell/weather.py b/homeassistant/components/climacell/weather.py index 7183a3ebcf..9c80a547f0 100644 --- a/homeassistant/components/climacell/weather.py +++ b/homeassistant/components/climacell/weather.py @@ -2,9 +2,10 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Mapping from datetime import datetime import logging -from typing import Any, Callable, Mapping +from typing import Any, Callable from pyclimacell.const import ( CURRENT, diff --git a/homeassistant/components/climate/reproduce_state.py b/homeassistant/components/climate/reproduce_state.py index be52138e3e..767a38b2e5 100644 --- a/homeassistant/components/climate/reproduce_state.py +++ b/homeassistant/components/climate/reproduce_state.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any from homeassistant.const import ATTR_TEMPERATURE from homeassistant.core import Context, HomeAssistant, State diff --git a/homeassistant/components/counter/reproduce_state.py b/homeassistant/components/counter/reproduce_state.py index 8fb15bd84e..0ced9bad06 100644 --- a/homeassistant/components/counter/reproduce_state.py +++ b/homeassistant/components/counter/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, HomeAssistant, State diff --git a/homeassistant/components/cover/reproduce_state.py b/homeassistant/components/cover/reproduce_state.py index 3b82596a21..c96b9ec5ac 100644 --- a/homeassistant/components/cover/reproduce_state.py +++ b/homeassistant/components/cover/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.components.cover import ( ATTR_CURRENT_POSITION, diff --git a/homeassistant/components/denonavr/media_player.py b/homeassistant/components/denonavr/media_player.py index 799f07ed71..d7e0f8510d 100644 --- a/homeassistant/components/denonavr/media_player.py +++ b/homeassistant/components/denonavr/media_player.py @@ -1,9 +1,10 @@ """Support for Denon AVR receivers using their HTTP interface.""" +from __future__ import annotations +from collections.abc import Coroutine from datetime import timedelta from functools import wraps import logging -from typing import Coroutine from denonavr import DenonAVR from denonavr.const import POWER_ON diff --git a/homeassistant/components/device_automation/__init__.py b/homeassistant/components/device_automation/__init__.py index 4741dbdb7f..12083a8d13 100644 --- a/homeassistant/components/device_automation/__init__.py +++ b/homeassistant/components/device_automation/__init__.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import MutableMapping from functools import wraps from types import ModuleType -from typing import Any, MutableMapping +from typing import Any import voluptuous as vol import voluptuous_serialize diff --git a/homeassistant/components/device_tracker/legacy.py b/homeassistant/components/device_tracker/legacy.py index 2614bd4228..e1eb897f1b 100644 --- a/homeassistant/components/device_tracker/legacy.py +++ b/homeassistant/components/device_tracker/legacy.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Sequence from datetime import timedelta import hashlib from types import ModuleType -from typing import Any, Callable, Sequence, final +from typing import Any, Callable, final import attr import voluptuous as vol diff --git a/homeassistant/components/directv/remote.py b/homeassistant/components/directv/remote.py index d1a4d236eb..dc28e287f5 100644 --- a/homeassistant/components/directv/remote.py +++ b/homeassistant/components/directv/remote.py @@ -1,9 +1,10 @@ """Support for the DIRECTV remote.""" from __future__ import annotations +from collections.abc import Iterable from datetime import timedelta import logging -from typing import Any, Callable, Iterable +from typing import Any, Callable from directv import DIRECTV, DIRECTVError diff --git a/homeassistant/components/fan/reproduce_state.py b/homeassistant/components/fan/reproduce_state.py index c9da43ebe3..2d4244ec2d 100644 --- a/homeassistant/components/fan/reproduce_state.py +++ b/homeassistant/components/fan/reproduce_state.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging from types import MappingProxyType -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/gogogate2/common.py b/homeassistant/components/gogogate2/common.py index e8b17184bb..8a51b210c5 100644 --- a/homeassistant/components/gogogate2/common.py +++ b/homeassistant/components/gogogate2/common.py @@ -1,9 +1,10 @@ """Common code for GogoGate2 component.""" from __future__ import annotations +from collections.abc import Awaitable from datetime import timedelta import logging -from typing import Awaitable, Callable, NamedTuple +from typing import Callable, NamedTuple from gogogate2_api import AbstractGateApi, GogoGate2Api, ISmartGateApi from gogogate2_api.common import AbstractDoor, get_door_by_id diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index 5af53768bc..096108b460 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -3,9 +3,10 @@ from __future__ import annotations from abc import abstractmethod import asyncio +from collections.abc import Iterable from contextvars import ContextVar import logging -from typing import Any, Iterable, List, cast +from typing import Any, List, cast import voluptuous as vol diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index b45dd1ec5e..26cc8e1c11 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -3,8 +3,9 @@ from __future__ import annotations import asyncio from collections import Counter +from collections.abc import Iterator import itertools -from typing import Any, Callable, Iterator, cast +from typing import Any, Callable, cast import voluptuous as vol diff --git a/homeassistant/components/group/reproduce_state.py b/homeassistant/components/group/reproduce_state.py index ea21c147b9..c99f098b22 100644 --- a/homeassistant/components/group/reproduce_state.py +++ b/homeassistant/components/group/reproduce_state.py @@ -1,7 +1,8 @@ """Module that groups code required to handle state restore for component.""" from __future__ import annotations -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any from homeassistant.core import Context, HomeAssistant, State from homeassistant.helpers.state import async_reproduce_state diff --git a/homeassistant/components/guardian/util.py b/homeassistant/components/guardian/util.py index ad2a074564..884bbcde7c 100644 --- a/homeassistant/components/guardian/util.py +++ b/homeassistant/components/guardian/util.py @@ -1,7 +1,10 @@ """Define Guardian-specific utilities.""" +from __future__ import annotations + import asyncio +from collections.abc import Awaitable from datetime import timedelta -from typing import Awaitable, Callable +from typing import Callable from aioguardian import Client from aioguardian.errors import GuardianError diff --git a/homeassistant/components/harmony/data.py b/homeassistant/components/harmony/data.py index 340596ff1e..6fdf18df61 100644 --- a/homeassistant/components/harmony/data.py +++ b/homeassistant/components/harmony/data.py @@ -1,7 +1,8 @@ """Harmony data object which contains the Harmony Client.""" +from __future__ import annotations +from collections.abc import Iterable import logging -from typing import Iterable from aioharmony.const import ClientCallbackType, SendCommandDevice import aioharmony.exceptions as aioexc diff --git a/homeassistant/components/heos/media_player.py b/homeassistant/components/heos/media_player.py index 6e271bf60c..b919db5834 100644 --- a/homeassistant/components/heos/media_player.py +++ b/homeassistant/components/heos/media_player.py @@ -1,8 +1,10 @@ """Denon HEOS Media Player.""" +from __future__ import annotations + +from collections.abc import Sequence from functools import reduce, wraps import logging from operator import ior -from typing import Sequence from pyheos import HeosError, const as heos_const diff --git a/homeassistant/components/history/__init__.py b/homeassistant/components/history/__init__.py index 09f459b32d..35be51a99d 100644 --- a/homeassistant/components/history/__init__.py +++ b/homeassistant/components/history/__init__.py @@ -2,12 +2,13 @@ from __future__ import annotations from collections import defaultdict +from collections.abc import Iterable from datetime import datetime as dt, timedelta from itertools import groupby import json import logging import time -from typing import Iterable, cast +from typing import cast from aiohttp import web from sqlalchemy import and_, bindparam, func, not_, or_ diff --git a/homeassistant/components/http/data_validator.py b/homeassistant/components/http/data_validator.py index d63912360a..2768350c18 100644 --- a/homeassistant/components/http/data_validator.py +++ b/homeassistant/components/http/data_validator.py @@ -1,7 +1,10 @@ """Decorator for view methods to help with data validation.""" +from __future__ import annotations + +from collections.abc import Awaitable from functools import wraps import logging -from typing import Any, Awaitable, Callable +from typing import Any, Callable from aiohttp import web import voluptuous as vol diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index da21894745..0384c872d4 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from bisect import bisect import logging import re -from typing import Callable, NamedTuple, Pattern +from typing import Callable, NamedTuple import attr @@ -52,8 +52,8 @@ class SensorMeta(NamedTuple): icon: str | Callable[[StateType], str] | None = None unit: str | None = None enabled_default: bool = False - include: Pattern[str] | None = None - exclude: Pattern[str] | None = None + include: re.Pattern[str] | None = None + exclude: re.Pattern[str] | None = None formatter: Callable[[str], tuple[StateType, str | None]] | None = None diff --git a/homeassistant/components/humidifier/reproduce_state.py b/homeassistant/components/humidifier/reproduce_state.py index 3f73ebf4e0..1303dee451 100644 --- a/homeassistant/components/humidifier/reproduce_state.py +++ b/homeassistant/components/humidifier/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_MODE, diff --git a/homeassistant/components/hyperion/light.py b/homeassistant/components/hyperion/light.py index ac2160120c..f8d760c0a9 100644 --- a/homeassistant/components/hyperion/light.py +++ b/homeassistant/components/hyperion/light.py @@ -1,10 +1,11 @@ """Support for Hyperion-NG remotes.""" from __future__ import annotations +from collections.abc import Mapping, Sequence import functools import logging from types import MappingProxyType -from typing import Any, Callable, Mapping, Sequence +from typing import Any, Callable from hyperion import client, const diff --git a/homeassistant/components/input_boolean/reproduce_state.py b/homeassistant/components/input_boolean/reproduce_state.py index 5fe7e779a9..961345b742 100644 --- a/homeassistant/components/input_boolean/reproduce_state.py +++ b/homeassistant/components/input_boolean/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/input_datetime/reproduce_state.py b/homeassistant/components/input_datetime/reproduce_state.py index f996721eab..230a0ed235 100644 --- a/homeassistant/components/input_datetime/reproduce_state.py +++ b/homeassistant/components/input_datetime/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, HomeAssistant, State diff --git a/homeassistant/components/input_number/reproduce_state.py b/homeassistant/components/input_number/reproduce_state.py index a897aec2ba..c198236789 100644 --- a/homeassistant/components/input_number/reproduce_state.py +++ b/homeassistant/components/input_number/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any import voluptuous as vol diff --git a/homeassistant/components/input_select/reproduce_state.py b/homeassistant/components/input_select/reproduce_state.py index 5ea7072e93..a2cb2cadd0 100644 --- a/homeassistant/components/input_select/reproduce_state.py +++ b/homeassistant/components/input_select/reproduce_state.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging from types import MappingProxyType -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, HomeAssistant, State diff --git a/homeassistant/components/input_text/reproduce_state.py b/homeassistant/components/input_text/reproduce_state.py index ce1b7c12c4..56a03b0d13 100644 --- a/homeassistant/components/input_text/reproduce_state.py +++ b/homeassistant/components/input_text/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, HomeAssistant, State diff --git a/homeassistant/components/knx/binary_sensor.py b/homeassistant/components/knx/binary_sensor.py index 47462f272d..455fd877c0 100644 --- a/homeassistant/components/knx/binary_sensor.py +++ b/homeassistant/components/knx/binary_sensor.py @@ -1,7 +1,8 @@ """Support for KNX/IP binary sensors.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx.devices import BinarySensor as XknxBinarySensor diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index ca3f7b0f22..63a8bd634d 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -1,7 +1,8 @@ """Support for KNX/IP climate devices.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx.devices import Climate as XknxClimate from xknx.dpt.dpt_hvac_mode import HVACControllerMode, HVACOperationMode diff --git a/homeassistant/components/knx/cover.py b/homeassistant/components/knx/cover.py index c45d057c3a..10f1be57be 100644 --- a/homeassistant/components/knx/cover.py +++ b/homeassistant/components/knx/cover.py @@ -1,8 +1,9 @@ """Support for KNX/IP covers.""" from __future__ import annotations +from collections.abc import Iterable from datetime import datetime -from typing import Any, Callable, Iterable +from typing import Any, Callable from xknx.devices import Cover as XknxCover, Device as XknxDevice diff --git a/homeassistant/components/knx/fan.py b/homeassistant/components/knx/fan.py index 38680e15bf..ca8ce74a52 100644 --- a/homeassistant/components/knx/fan.py +++ b/homeassistant/components/knx/fan.py @@ -1,8 +1,9 @@ """Support for KNX/IP fans.""" from __future__ import annotations +from collections.abc import Iterable import math -from typing import Any, Callable, Iterable +from typing import Any, Callable from xknx.devices import Fan as XknxFan diff --git a/homeassistant/components/knx/light.py b/homeassistant/components/knx/light.py index 0eb6243373..26bd27baa7 100644 --- a/homeassistant/components/knx/light.py +++ b/homeassistant/components/knx/light.py @@ -1,7 +1,8 @@ """Support for KNX/IP lights.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx.devices import Light as XknxLight diff --git a/homeassistant/components/knx/scene.py b/homeassistant/components/knx/scene.py index ff08cdf411..d845cb9467 100644 --- a/homeassistant/components/knx/scene.py +++ b/homeassistant/components/knx/scene.py @@ -1,7 +1,8 @@ """Support for KNX scenes.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx.devices import Scene as XknxScene diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index f75f483b9f..51951304f9 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -1,7 +1,8 @@ """Support for KNX/IP sensors.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx.devices import Sensor as XknxSensor diff --git a/homeassistant/components/knx/switch.py b/homeassistant/components/knx/switch.py index c52beaea2e..fa8a33cc5b 100644 --- a/homeassistant/components/knx/switch.py +++ b/homeassistant/components/knx/switch.py @@ -1,7 +1,8 @@ """Support for KNX/IP switches.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from xknx import XKNX from xknx.devices import Switch as XknxSwitch diff --git a/homeassistant/components/knx/weather.py b/homeassistant/components/knx/weather.py index cc2f3c0a09..1a29e7d8e1 100644 --- a/homeassistant/components/knx/weather.py +++ b/homeassistant/components/knx/weather.py @@ -1,7 +1,8 @@ """Support for KNX/IP weather station.""" from __future__ import annotations -from typing import Callable, Iterable +from collections.abc import Iterable +from typing import Callable from xknx.devices import Weather as XknxWeather diff --git a/homeassistant/components/light/reproduce_state.py b/homeassistant/components/light/reproduce_state.py index 68fac8aa5c..fa70670eee 100644 --- a/homeassistant/components/light/reproduce_state.py +++ b/homeassistant/components/light/reproduce_state.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging from types import MappingProxyType -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/lock/reproduce_state.py b/homeassistant/components/lock/reproduce_state.py index 0d575964b2..e7e79f49be 100644 --- a/homeassistant/components/lock/reproduce_state.py +++ b/homeassistant/components/lock/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/media_player/reproduce_state.py b/homeassistant/components/media_player/reproduce_state.py index 1707109197..5d491a83ce 100644 --- a/homeassistant/components/media_player/reproduce_state.py +++ b/homeassistant/components/media_player/reproduce_state.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any from homeassistant.const import ( SERVICE_MEDIA_PAUSE, diff --git a/homeassistant/components/minio/minio_helper.py b/homeassistant/components/minio/minio_helper.py index f2d8606755..c77e41727a 100644 --- a/homeassistant/components/minio/minio_helper.py +++ b/homeassistant/components/minio/minio_helper.py @@ -1,14 +1,13 @@ """Minio helper methods.""" from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Iterable, Iterator import json import logging from queue import Queue import re import threading import time -from typing import Iterator from urllib.parse import unquote from minio import Minio diff --git a/homeassistant/components/mysensors/gateway.py b/homeassistant/components/mysensors/gateway.py index 6cf8e7d738..dc6caa9394 100644 --- a/homeassistant/components/mysensors/gateway.py +++ b/homeassistant/components/mysensors/gateway.py @@ -3,10 +3,11 @@ from __future__ import annotations import asyncio from collections import defaultdict +from collections.abc import Coroutine import logging import socket import sys -from typing import Any, Callable, Coroutine +from typing import Any, Callable import async_timeout from mysensors import BaseAsyncGateway, Message, Sensor, mysensors diff --git a/homeassistant/components/mysensors/helpers.py b/homeassistant/components/mysensors/helpers.py index 0d18b24352..71ea97bc37 100644 --- a/homeassistant/components/mysensors/helpers.py +++ b/homeassistant/components/mysensors/helpers.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections import defaultdict from enum import IntEnum import logging -from typing import Callable, DefaultDict +from typing import Callable from mysensors import BaseAsyncGateway, Message from mysensors.sensor import ChildSensor @@ -174,9 +174,9 @@ def validate_child( node_id: int, child: ChildSensor, value_type: int | None = None, -) -> DefaultDict[str, list[DevId]]: +) -> defaultdict[str, list[DevId]]: """Validate a child. Returns a dict mapping hass platform names to list of DevId.""" - validated: DefaultDict[str, list[DevId]] = defaultdict(list) + validated: defaultdict[str, list[DevId]] = defaultdict(list) pres: IntEnum = gateway.const.Presentation set_req: IntEnum = gateway.const.SetReq child_type_name: SensorType | None = next( diff --git a/homeassistant/components/netatmo/data_handler.py b/homeassistant/components/netatmo/data_handler.py index 6982a651a4..41e7d158c0 100644 --- a/homeassistant/components/netatmo/data_handler.py +++ b/homeassistant/components/netatmo/data_handler.py @@ -7,7 +7,6 @@ from functools import partial from itertools import islice import logging from time import time -from typing import Deque import pyatmo @@ -60,7 +59,7 @@ class NetatmoDataHandler: self.listeners: list[CALLBACK_TYPE] = [] self._data_classes: dict = {} self.data = {} - self._queue: Deque = deque() + self._queue = deque() self._webhook: bool = False async def async_setup(self): diff --git a/homeassistant/components/number/reproduce_state.py b/homeassistant/components/number/reproduce_state.py index 4364dffe1e..d628db825c 100644 --- a/homeassistant/components/number/reproduce_state.py +++ b/homeassistant/components/number/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, State diff --git a/homeassistant/components/nws/__init__.py b/homeassistant/components/nws/__init__.py index 5724175b4b..021b996c94 100644 --- a/homeassistant/components/nws/__init__.py +++ b/homeassistant/components/nws/__init__.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable import datetime import logging -from typing import Awaitable, Callable +from typing import Callable from pynws import SimpleNWS diff --git a/homeassistant/components/persistent_notification/__init__.py b/homeassistant/components/persistent_notification/__init__.py index 05d52cf783..071261e7b2 100644 --- a/homeassistant/components/persistent_notification/__init__.py +++ b/homeassistant/components/persistent_notification/__init__.py @@ -2,8 +2,9 @@ from __future__ import annotations from collections import OrderedDict +from collections.abc import Mapping, MutableMapping import logging -from typing import Any, Mapping, MutableMapping +from typing import Any import voluptuous as vol diff --git a/homeassistant/components/rainmachine/switch.py b/homeassistant/components/rainmachine/switch.py index 6741abbfc9..f901600c98 100644 --- a/homeassistant/components/rainmachine/switch.py +++ b/homeassistant/components/rainmachine/switch.py @@ -1,6 +1,9 @@ """This component provides support for RainMachine programs and zones.""" +from __future__ import annotations + +from collections.abc import Coroutine from datetime import datetime -from typing import Callable, Coroutine +from typing import Callable from regenmaschine.controller import Controller from regenmaschine.errors import RequestError diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index ecde6f67b6..94c54dd323 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -1,10 +1,11 @@ """Support to interface with universal remote control devices.""" from __future__ import annotations +from collections.abc import Iterable from datetime import timedelta import functools as ft import logging -from typing import Any, Iterable, cast, final +from typing import Any, cast, final import voluptuous as vol diff --git a/homeassistant/components/remote/reproduce_state.py b/homeassistant/components/remote/reproduce_state.py index b42a0bdc61..24f748d4a0 100644 --- a/homeassistant/components/remote/reproduce_state.py +++ b/homeassistant/components/remote/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/sharkiq/vacuum.py b/homeassistant/components/sharkiq/vacuum.py index eed41fb143..dd6e676670 100644 --- a/homeassistant/components/sharkiq/vacuum.py +++ b/homeassistant/components/sharkiq/vacuum.py @@ -1,8 +1,8 @@ """Shark IQ Wrapper.""" from __future__ import annotations +from collections.abc import Iterable import logging -from typing import Iterable from sharkiqpy import OperatingModes, PowerModes, Properties, SharkIqVacuum diff --git a/homeassistant/components/sma/__init__.py b/homeassistant/components/sma/__init__.py index e17437db06..6ca5fe712b 100644 --- a/homeassistant/components/sma/__init__.py +++ b/homeassistant/components/sma/__init__.py @@ -1,8 +1,9 @@ """The sma integration.""" +from __future__ import annotations + import asyncio from datetime import timedelta import logging -from typing import List import pysma @@ -40,7 +41,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -def _parse_legacy_options(entry: ConfigEntry, sensor_def: pysma.Sensors) -> List[str]: +def _parse_legacy_options(entry: ConfigEntry, sensor_def: pysma.Sensors) -> list[str]: """Parse legacy configuration options. This will parse the legacy CONF_SENSORS and CONF_CUSTOM configuration options @@ -89,7 +90,7 @@ def _migrate_old_unique_ids( hass: HomeAssistant, entry: ConfigEntry, sensor_def: pysma.Sensors, - config_sensors: List[str], + config_sensors: list[str], ) -> None: """Migrate legacy sensor entity_id format to new format.""" entity_registry = er.async_get(hass) diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index ea5b566640..4e950651ab 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -1,8 +1,9 @@ """SMA Solar Webconnect interface.""" from __future__ import annotations +from collections.abc import Coroutine import logging -from typing import Any, Callable, Coroutine +from typing import Any, Callable import pysma import voluptuous as vol diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index 77ef913c62..d36739c955 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -1,8 +1,10 @@ """Support for SmartThings Cloud.""" +from __future__ import annotations + import asyncio +from collections.abc import Iterable import importlib import logging -from typing import Iterable from aiohttp.client_exceptions import ClientConnectionError, ClientResponseError from pysmartapp.event import EVENT_TYPE_DEVICE diff --git a/homeassistant/components/smartthings/binary_sensor.py b/homeassistant/components/smartthings/binary_sensor.py index dd4c1e2928..74eb253ebb 100644 --- a/homeassistant/components/smartthings/binary_sensor.py +++ b/homeassistant/components/smartthings/binary_sensor.py @@ -1,7 +1,7 @@ """Support for binary sensors through the SmartThings cloud API.""" from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/smartthings/climate.py b/homeassistant/components/smartthings/climate.py index 76c168fbc3..da9e0fd090 100644 --- a/homeassistant/components/smartthings/climate.py +++ b/homeassistant/components/smartthings/climate.py @@ -2,9 +2,8 @@ from __future__ import annotations import asyncio -from collections.abc import Iterable +from collections.abc import Iterable, Sequence import logging -from typing import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/smartthings/cover.py b/homeassistant/components/smartthings/cover.py index 8fff4ebbdf..66715edfe6 100644 --- a/homeassistant/components/smartthings/cover.py +++ b/homeassistant/components/smartthings/cover.py @@ -1,7 +1,7 @@ """Support for covers through the SmartThings cloud API.""" from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/smartthings/fan.py b/homeassistant/components/smartthings/fan.py index 167f3a38ed..62b84b1909 100644 --- a/homeassistant/components/smartthings/fan.py +++ b/homeassistant/components/smartthings/fan.py @@ -1,8 +1,8 @@ """Support for fans through the SmartThings cloud API.""" from __future__ import annotations +from collections.abc import Sequence import math -from typing import Sequence from pysmartthings import Capability diff --git a/homeassistant/components/smartthings/light.py b/homeassistant/components/smartthings/light.py index de678f255f..cba4439368 100644 --- a/homeassistant/components/smartthings/light.py +++ b/homeassistant/components/smartthings/light.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Capability diff --git a/homeassistant/components/smartthings/lock.py b/homeassistant/components/smartthings/lock.py index 2cd0b283cc..601e207a6f 100644 --- a/homeassistant/components/smartthings/lock.py +++ b/homeassistant/components/smartthings/lock.py @@ -1,7 +1,7 @@ """Support for locks through the SmartThings cloud API.""" from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index 533d8f6476..a7e2926036 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections import namedtuple -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/smartthings/switch.py b/homeassistant/components/smartthings/switch.py index d8bcd45541..7b8364d9ba 100644 --- a/homeassistant/components/smartthings/switch.py +++ b/homeassistant/components/smartthings/switch.py @@ -1,7 +1,7 @@ """Support for switches through the SmartThings cloud API.""" from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/components/solaredge/sensor.py b/homeassistant/components/solaredge/sensor.py index d827990ac5..2195c10cc1 100644 --- a/homeassistant/components/solaredge/sensor.py +++ b/homeassistant/components/solaredge/sensor.py @@ -2,9 +2,10 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Iterable from datetime import date, datetime, timedelta import logging -from typing import Any, Callable, Iterable +from typing import Any, Callable from requests.exceptions import ConnectTimeout, HTTPError from solaredge import Solaredge diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 3ee458ec9d..8c7b61e96e 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -2,12 +2,13 @@ from __future__ import annotations import asyncio +from collections.abc import Coroutine from contextlib import suppress import datetime import functools as ft import logging import socket -from typing import Any, Callable, Coroutine +from typing import Any, Callable import urllib.parse import async_timeout diff --git a/homeassistant/components/ssdp/__init__.py b/homeassistant/components/ssdp/__init__.py index b6e2897ade..d9f74e5e77 100644 --- a/homeassistant/components/ssdp/__init__.py +++ b/homeassistant/components/ssdp/__init__.py @@ -1,8 +1,11 @@ """The SSDP integration.""" +from __future__ import annotations + import asyncio +from collections.abc import Mapping from datetime import timedelta import logging -from typing import Any, Mapping +from typing import Any import aiohttp from async_upnp_client.search import async_search diff --git a/homeassistant/components/stream/recorder.py b/homeassistant/components/stream/recorder.py index 01a8ca9ea6..f5393078ab 100644 --- a/homeassistant/components/stream/recorder.py +++ b/homeassistant/components/stream/recorder.py @@ -1,10 +1,10 @@ """Provide functionality to record stream.""" from __future__ import annotations +from collections import deque import logging import os import threading -from typing import Deque import av @@ -21,7 +21,7 @@ def async_setup_recorder(hass): """Only here so Provider Registry works.""" -def recorder_save_worker(file_out: str, segments: Deque[Segment]): +def recorder_save_worker(file_out: str, segments: deque[Segment]): """Handle saving stream.""" if not segments: diff --git a/homeassistant/components/switch/light.py b/homeassistant/components/switch/light.py index e215481052..039090d312 100644 --- a/homeassistant/components/switch/light.py +++ b/homeassistant/components/switch/light.py @@ -1,7 +1,8 @@ """Light support for switch entities.""" from __future__ import annotations -from typing import Any, Callable, Sequence, cast +from collections.abc import Sequence +from typing import Any, Callable, cast import voluptuous as vol diff --git a/homeassistant/components/switch/reproduce_state.py b/homeassistant/components/switch/reproduce_state.py index 94fd836631..4cc1ec1f69 100644 --- a/homeassistant/components/switch/reproduce_state.py +++ b/homeassistant/components/switch/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/system_health/__init__.py b/homeassistant/components/system_health/__init__.py index 2ad4863dbe..a7a92d3baf 100644 --- a/homeassistant/components/system_health/__init__.py +++ b/homeassistant/components/system_health/__init__.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable import dataclasses from datetime import datetime import logging -from typing import Awaitable, Callable +from typing import Callable import aiohttp import async_timeout diff --git a/homeassistant/components/timer/reproduce_state.py b/homeassistant/components/timer/reproduce_state.py index 377f8a1dda..3ab7d4815c 100644 --- a/homeassistant/components/timer/reproduce_state.py +++ b/homeassistant/components/timer/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import Context, State diff --git a/homeassistant/components/trace/__init__.py b/homeassistant/components/trace/__init__.py index eca22a56da..e845f92806 100644 --- a/homeassistant/components/trace/__init__.py +++ b/homeassistant/components/trace/__init__.py @@ -1,9 +1,10 @@ """Support for script and automation tracing and debugging.""" from __future__ import annotations +from collections import deque import datetime as dt from itertools import count -from typing import Any, Deque +from typing import Any from homeassistant.core import Context from homeassistant.helpers.trace import ( @@ -52,7 +53,7 @@ class ActionTrace: context: Context, ): """Container for script trace.""" - self._trace: dict[str, Deque[TraceElement]] | None = None + self._trace: dict[str, deque[TraceElement]] | None = None self._config: dict[str, Any] = config self._blueprint_inputs: dict[str, Any] = blueprint_inputs self.context: Context = context @@ -67,7 +68,7 @@ class ActionTrace: trace_set_child_id(self.key, self.run_id) trace_id_set((key, self.run_id)) - def set_trace(self, trace: dict[str, Deque[TraceElement]]) -> None: + def set_trace(self, trace: dict[str, deque[TraceElement]]) -> None: """Set trace.""" self._trace = trace diff --git a/homeassistant/components/upnp/config_flow.py b/homeassistant/components/upnp/config_flow.py index 7a1a3d4a06..51e3401793 100644 --- a/homeassistant/components/upnp/config_flow.py +++ b/homeassistant/components/upnp/config_flow.py @@ -1,8 +1,9 @@ """Config flow for UPNP.""" from __future__ import annotations +from collections.abc import Mapping from datetime import timedelta -from typing import Any, Mapping +from typing import Any import voluptuous as vol diff --git a/homeassistant/components/upnp/device.py b/homeassistant/components/upnp/device.py index aafd9f5151..c116e64ca7 100644 --- a/homeassistant/components/upnp/device.py +++ b/homeassistant/components/upnp/device.py @@ -2,8 +2,8 @@ from __future__ import annotations import asyncio +from collections.abc import Mapping from ipaddress import IPv4Address -from typing import Mapping from urllib.parse import urlparse from async_upnp_client import UpnpFactory diff --git a/homeassistant/components/vacuum/reproduce_state.py b/homeassistant/components/vacuum/reproduce_state.py index 38958bd479..4d5a9baf46 100644 --- a/homeassistant/components/vacuum/reproduce_state.py +++ b/homeassistant/components/vacuum/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/vera/common.py b/homeassistant/components/vera/common.py index fcc501c209..243ee4d759 100644 --- a/homeassistant/components/vera/common.py +++ b/homeassistant/components/vera/common.py @@ -1,7 +1,8 @@ """Common vera code.""" from __future__ import annotations -from typing import DefaultDict, NamedTuple +from collections import defaultdict +from typing import NamedTuple import pyvera as pv @@ -17,7 +18,7 @@ class ControllerData(NamedTuple): """Controller data.""" controller: pv.VeraController - devices: DefaultDict[str, list[pv.VeraDevice]] + devices: defaultdict[str, list[pv.VeraDevice]] scenes: list[pv.VeraScene] config_entry: ConfigEntry diff --git a/homeassistant/components/verisure/alarm_control_panel.py b/homeassistant/components/verisure/alarm_control_panel.py index 1cefd6af27..b84affe9e8 100644 --- a/homeassistant/components/verisure/alarm_control_panel.py +++ b/homeassistant/components/verisure/alarm_control_panel.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from homeassistant.components.alarm_control_panel import ( FORMAT_NUMBER, diff --git a/homeassistant/components/verisure/binary_sensor.py b/homeassistant/components/verisure/binary_sensor.py index 3363178efe..758636bee9 100644 --- a/homeassistant/components/verisure/binary_sensor.py +++ b/homeassistant/components/verisure/binary_sensor.py @@ -1,7 +1,8 @@ """Support for Verisure binary sensors.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from homeassistant.components.binary_sensor import ( DEVICE_CLASS_CONNECTIVITY, diff --git a/homeassistant/components/verisure/camera.py b/homeassistant/components/verisure/camera.py index e667829bb1..a4442d2ae4 100644 --- a/homeassistant/components/verisure/camera.py +++ b/homeassistant/components/verisure/camera.py @@ -1,9 +1,10 @@ """Support for Verisure cameras.""" from __future__ import annotations +from collections.abc import Iterable import errno import os -from typing import Any, Callable, Iterable +from typing import Any, Callable from verisure import Error as VerisureError diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index eeec7e53a0..bcd5ac214e 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from verisure import Error as VerisureError diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 93e1793da8..72b061bd62 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -1,7 +1,8 @@ """Support for Verisure sensors.""" from __future__ import annotations -from typing import Any, Callable, Iterable +from collections.abc import Iterable +from typing import Any, Callable from homeassistant.components.sensor import ( DEVICE_CLASS_HUMIDITY, diff --git a/homeassistant/components/verisure/switch.py b/homeassistant/components/verisure/switch.py index f55db8ce42..a97758d17f 100644 --- a/homeassistant/components/verisure/switch.py +++ b/homeassistant/components/verisure/switch.py @@ -1,8 +1,9 @@ """Support for Verisure Smartplugs.""" from __future__ import annotations +from collections.abc import Iterable from time import monotonic -from typing import Any, Callable, Iterable +from typing import Any, Callable from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry diff --git a/homeassistant/components/water_heater/reproduce_state.py b/homeassistant/components/water_heater/reproduce_state.py index 4675cdb862..235eac5cd5 100644 --- a/homeassistant/components/water_heater/reproduce_state.py +++ b/homeassistant/components/water_heater/reproduce_state.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Any, Iterable +from typing import Any from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/homeassistant/components/websocket_api/connection.py b/homeassistant/components/websocket_api/connection.py index dd1bb33369..4e0ba257d5 100644 --- a/homeassistant/components/websocket_api/connection.py +++ b/homeassistant/components/websocket_api/connection.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Callable, Hashable +from collections.abc import Hashable +from typing import Any, Callable import voluptuous as vol diff --git a/homeassistant/components/websocket_api/decorators.py b/homeassistant/components/websocket_api/decorators.py index 283734f757..cbb0e8563c 100644 --- a/homeassistant/components/websocket_api/decorators.py +++ b/homeassistant/components/websocket_api/decorators.py @@ -1,7 +1,10 @@ """Decorators for the Websocket API.""" +from __future__ import annotations + import asyncio +from collections.abc import Awaitable from functools import wraps -from typing import Awaitable, Callable +from typing import Callable from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import Unauthorized diff --git a/homeassistant/components/wemo/entity.py b/homeassistant/components/wemo/entity.py index d10707f459..904d62639e 100644 --- a/homeassistant/components/wemo/entity.py +++ b/homeassistant/components/wemo/entity.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Generator import contextlib import logging -from typing import Any, Generator +from typing import Any import async_timeout from pywemo import WeMoDevice diff --git a/homeassistant/components/xbox/remote.py b/homeassistant/components/xbox/remote.py index 12d9a6336c..31e6220172 100644 --- a/homeassistant/components/xbox/remote.py +++ b/homeassistant/components/xbox/remote.py @@ -1,7 +1,10 @@ """Xbox Remote support.""" +from __future__ import annotations + import asyncio +from collections.abc import Iterable import re -from typing import Any, Iterable +from typing import Any from xbox.webapi.api.client import XboxLiveClient from xbox.webapi.api.provider.smartglass.models import ( diff --git a/homeassistant/components/zha/core/channels/general.py b/homeassistant/components/zha/core/channels/general.py index 6ef0bd9e66..3bd08e6f93 100644 --- a/homeassistant/components/zha/core/channels/general.py +++ b/homeassistant/components/zha/core/channels/general.py @@ -2,7 +2,8 @@ from __future__ import annotations import asyncio -from typing import Any, Coroutine +from collections.abc import Coroutine +from typing import Any import zigpy.exceptions import zigpy.zcl.clusters.general as general diff --git a/homeassistant/components/zha/core/channels/homeautomation.py b/homeassistant/components/zha/core/channels/homeautomation.py index 989cc17f97..6e9d413862 100644 --- a/homeassistant/components/zha/core/channels/homeautomation.py +++ b/homeassistant/components/zha/core/channels/homeautomation.py @@ -1,7 +1,7 @@ """Home automation channels module for Zigbee Home Automation.""" from __future__ import annotations -from typing import Coroutine +from collections.abc import Coroutine import zigpy.zcl.clusters.homeautomation as homeautomation diff --git a/homeassistant/components/zha/core/channels/lighting.py b/homeassistant/components/zha/core/channels/lighting.py index eef4c56e37..8c2b2bddd6 100644 --- a/homeassistant/components/zha/core/channels/lighting.py +++ b/homeassistant/components/zha/core/channels/lighting.py @@ -1,8 +1,8 @@ """Lighting channels module for Zigbee Home Automation.""" from __future__ import annotations +from collections.abc import Coroutine from contextlib import suppress -from typing import Coroutine import zigpy.zcl.clusters.lighting as lighting diff --git a/homeassistant/components/zha/core/channels/security.py b/homeassistant/components/zha/core/channels/security.py index 7c600d9840..313d016935 100644 --- a/homeassistant/components/zha/core/channels/security.py +++ b/homeassistant/components/zha/core/channels/security.py @@ -4,8 +4,10 @@ Security channels module for Zigbee Home Automation. For more details about this component, please refer to the documentation at https://home-assistant.io/integrations/zha/ """ +from __future__ import annotations + import asyncio -from typing import Coroutine +from collections.abc import Coroutine from zigpy.exceptions import ZigbeeException import zigpy.zcl.clusters.security as security diff --git a/homeassistant/components/zha/core/channels/smartenergy.py b/homeassistant/components/zha/core/channels/smartenergy.py index a815c75c8b..cfe395773a 100644 --- a/homeassistant/components/zha/core/channels/smartenergy.py +++ b/homeassistant/components/zha/core/channels/smartenergy.py @@ -1,7 +1,7 @@ """Smart energy channels module for Zigbee Home Automation.""" from __future__ import annotations -from typing import Coroutine +from collections.abc import Coroutine import zigpy.zcl.clusters.smartenergy as smartenergy diff --git a/homeassistant/components/zha/core/helpers.py b/homeassistant/components/zha/core/helpers.py index f8fb12e159..f38e4c2c69 100644 --- a/homeassistant/components/zha/core/helpers.py +++ b/homeassistant/components/zha/core/helpers.py @@ -8,13 +8,14 @@ from __future__ import annotations import asyncio import binascii +from collections.abc import Iterator from dataclasses import dataclass import functools import itertools import logging from random import uniform import re -from typing import Any, Callable, Iterator +from typing import Any, Callable import voluptuous as vol import zigpy.exceptions diff --git a/homeassistant/components/zha/core/store.py b/homeassistant/components/zha/core/store.py index 9381c52918..c4bbca2567 100644 --- a/homeassistant/components/zha/core/store.py +++ b/homeassistant/components/zha/core/store.py @@ -2,9 +2,10 @@ from __future__ import annotations from collections import OrderedDict +from collections.abc import MutableMapping import datetime import time -from typing import MutableMapping, cast +from typing import cast import attr diff --git a/homeassistant/components/zha/entity.py b/homeassistant/components/zha/entity.py index 445151899e..2e5fe93543 100644 --- a/homeassistant/components/zha/entity.py +++ b/homeassistant/components/zha/entity.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable import functools import logging -from typing import Any, Awaitable +from typing import Any from homeassistant.const import ATTR_NAME from homeassistant.core import CALLBACK_TYPE, Event, callback diff --git a/homeassistant/components/zwave_js/discovery.py b/homeassistant/components/zwave_js/discovery.py index 17ae01aa9b..a7df9998f6 100644 --- a/homeassistant/components/zwave_js/discovery.py +++ b/homeassistant/components/zwave_js/discovery.py @@ -1,8 +1,9 @@ """Map Z-Wave nodes and values to Home Assistant entities.""" from __future__ import annotations +from collections.abc import Generator from dataclasses import dataclass -from typing import Any, Generator +from typing import Any from zwave_js_server.const import CommandClass from zwave_js_server.model.device_class import DeviceClassItem diff --git a/homeassistant/config.py b/homeassistant/config.py index 362c93d04f..958dcea555 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -2,13 +2,14 @@ from __future__ import annotations from collections import OrderedDict +from collections.abc import Sequence import logging import os from pathlib import Path import re import shutil from types import ModuleType -from typing import Any, Callable, Sequence +from typing import Any, Callable from awesomeversion import AwesomeVersion import voluptuous as vol diff --git a/homeassistant/core.py b/homeassistant/core.py index 1356de0b57..3313da887c 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -7,6 +7,7 @@ of entities and react to changes. from __future__ import annotations import asyncio +from collections.abc import Awaitable, Collection, Iterable, Mapping import datetime import enum import functools @@ -17,19 +18,7 @@ import re import threading from time import monotonic from types import MappingProxyType -from typing import ( - TYPE_CHECKING, - Any, - Awaitable, - Callable, - Collection, - Coroutine, - Iterable, - Mapping, - Optional, - TypeVar, - cast, -) +from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar, cast import attr import voluptuous as vol diff --git a/homeassistant/exceptions.py b/homeassistant/exceptions.py index a081cfe3cc..844fd369ca 100644 --- a/homeassistant/exceptions.py +++ b/homeassistant/exceptions.py @@ -1,7 +1,8 @@ """The exceptions used by Home Assistant.""" from __future__ import annotations -from typing import TYPE_CHECKING, Generator, Sequence +from collections.abc import Generator, Sequence +from typing import TYPE_CHECKING import attr diff --git a/homeassistant/helpers/__init__.py b/homeassistant/helpers/__init__.py index a1964c432f..a0642e8ead 100644 --- a/homeassistant/helpers/__init__.py +++ b/homeassistant/helpers/__init__.py @@ -1,8 +1,9 @@ """Helper methods for components within Home Assistant.""" from __future__ import annotations +from collections.abc import Iterable, Sequence import re -from typing import TYPE_CHECKING, Any, Iterable, Sequence +from typing import TYPE_CHECKING, Any from homeassistant.const import CONF_PLATFORM diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 53b906efd3..0bb9a815c8 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable from contextlib import suppress from ssl import SSLContext import sys -from typing import Any, Awaitable, Callable, cast +from typing import Any, Callable, cast import aiohttp from aiohttp import web diff --git a/homeassistant/helpers/area_registry.py b/homeassistant/helpers/area_registry.py index af568b4041..67d713e508 100644 --- a/homeassistant/helpers/area_registry.py +++ b/homeassistant/helpers/area_registry.py @@ -2,7 +2,8 @@ from __future__ import annotations from collections import OrderedDict -from typing import Container, Iterable, MutableMapping, cast +from collections.abc import Container, Iterable, MutableMapping +from typing import cast import attr diff --git a/homeassistant/helpers/collection.py b/homeassistant/helpers/collection.py index 248059f7f9..bfffb8523d 100644 --- a/homeassistant/helpers/collection.py +++ b/homeassistant/helpers/collection.py @@ -3,10 +3,11 @@ from __future__ import annotations from abc import ABC, abstractmethod import asyncio +from collections.abc import Coroutine from dataclasses import dataclass from itertools import groupby import logging -from typing import Any, Awaitable, Callable, Coroutine, Iterable, Optional, cast +from typing import Any, Awaitable, Callable, Iterable, Optional, cast import voluptuous as vol from voluptuous.humanize import humanize_error diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index 18ef4c2082..138fa81947 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -3,13 +3,14 @@ from __future__ import annotations import asyncio from collections import deque +from collections.abc import Container, Generator from contextlib import contextmanager from datetime import datetime, timedelta import functools as ft import logging import re import sys -from typing import Any, Callable, Container, Generator, cast +from typing import Any, Callable, cast from homeassistant.components import zone as zone_cmp from homeassistant.components.device_automation import ( diff --git a/homeassistant/helpers/config_entry_oauth2_flow.py b/homeassistant/helpers/config_entry_oauth2_flow.py index 891d6c7d28..e19a065eb0 100644 --- a/homeassistant/helpers/config_entry_oauth2_flow.py +++ b/homeassistant/helpers/config_entry_oauth2_flow.py @@ -9,10 +9,11 @@ from __future__ import annotations from abc import ABC, ABCMeta, abstractmethod import asyncio +from collections.abc import Awaitable import logging import secrets import time -from typing import Any, Awaitable, Callable, Dict, cast +from typing import Any, Callable, Dict, cast from aiohttp import client, web import async_timeout diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index bbac18ab83..e0afbc49af 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -1,6 +1,7 @@ """Helpers for config validation using voluptuous.""" from __future__ import annotations +from collections.abc import Hashable from datetime import ( date as date_sys, datetime as datetime_sys, @@ -14,7 +15,7 @@ from numbers import Number import os import re from socket import _GLOBAL_DEFAULT_TIMEOUT # type: ignore # private, not in typeshed -from typing import Any, Callable, Dict, Hashable, Pattern, TypeVar, cast +from typing import Any, Callable, Dict, TypeVar, cast from urllib.parse import urlparse from uuid import UUID @@ -204,7 +205,7 @@ def matches_regex(regex: str) -> Callable[[Any], str]: return validator -def is_regex(value: Any) -> Pattern[Any]: +def is_regex(value: Any) -> re.Pattern[Any]: """Validate that a string is a valid regular expression.""" try: r = re.compile(value) diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index 705f48bbd7..8e7e57fa14 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable from logging import Logger -from typing import Any, Awaitable, Callable +from typing import Any, Callable from homeassistant.core import HassJob, HomeAssistant, callback diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index f30832479c..e6af7751c8 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -3,12 +3,12 @@ from __future__ import annotations from abc import ABC import asyncio -from collections.abc import Mapping +from collections.abc import Awaitable, Iterable, Mapping from datetime import datetime, timedelta import functools as ft import logging from timeit import default_timer as timer -from typing import Any, Awaitable, Iterable +from typing import Any from homeassistant.config import DATA_CUSTOMIZE from homeassistant.const import ( diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 46279fcb14..7ac221ea06 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -2,11 +2,12 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable from datetime import timedelta from itertools import chain import logging from types import ModuleType -from typing import Any, Callable, Iterable +from typing import Any, Callable import voluptuous as vol diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index ef45b8dcd9..abeeb40ca7 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -2,12 +2,13 @@ from __future__ import annotations import asyncio +from collections.abc import Coroutine, Iterable from contextvars import ContextVar from datetime import datetime, timedelta import logging from logging import Logger from types import ModuleType -from typing import TYPE_CHECKING, Callable, Coroutine, Iterable +from typing import TYPE_CHECKING, Callable from homeassistant import config_entries from homeassistant.const import ( diff --git a/homeassistant/helpers/entity_registry.py b/homeassistant/helpers/entity_registry.py index db16b3cc0b..936464dc42 100644 --- a/homeassistant/helpers/entity_registry.py +++ b/homeassistant/helpers/entity_registry.py @@ -10,8 +10,9 @@ timer. from __future__ import annotations from collections import OrderedDict +from collections.abc import Iterable import logging -from typing import TYPE_CHECKING, Any, Callable, Iterable, cast +from typing import TYPE_CHECKING, Any, Callable, cast import attr diff --git a/homeassistant/helpers/entity_values.py b/homeassistant/helpers/entity_values.py index 57dbb34c56..8f11fbf311 100644 --- a/homeassistant/helpers/entity_values.py +++ b/homeassistant/helpers/entity_values.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections import OrderedDict import fnmatch import re -from typing import Any, Pattern +from typing import Any from homeassistant.core import split_entity_id @@ -26,7 +26,7 @@ class EntityValues: self._domain = domain if glob is None: - compiled: dict[Pattern[str], Any] | None = None + compiled: dict[re.Pattern[str], Any] | None = None else: compiled = OrderedDict() for key, value in glob.items(): diff --git a/homeassistant/helpers/entityfilter.py b/homeassistant/helpers/entityfilter.py index ebde309de1..e026955f28 100644 --- a/homeassistant/helpers/entityfilter.py +++ b/homeassistant/helpers/entityfilter.py @@ -3,7 +3,7 @@ from __future__ import annotations import fnmatch import re -from typing import Callable, Pattern +from typing import Callable import voluptuous as vol @@ -104,12 +104,12 @@ INCLUDE_EXCLUDE_FILTER_SCHEMA = vol.All( ) -def _glob_to_re(glob: str) -> Pattern[str]: +def _glob_to_re(glob: str) -> re.Pattern[str]: """Translate and compile glob string into pattern.""" return re.compile(fnmatch.translate(glob)) -def _test_against_patterns(patterns: list[Pattern[str]], entity_id: str) -> bool: +def _test_against_patterns(patterns: list[re.Pattern[str]], entity_id: str) -> bool: """Test entity against list of patterns, true if any match.""" for pattern in patterns: if pattern.match(entity_id): diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 1a7e11ff5c..b8a8db8f03 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -2,13 +2,14 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable, Iterable import copy from dataclasses import dataclass from datetime import datetime, timedelta import functools as ft import logging import time -from typing import Any, Awaitable, Callable, Iterable, List, cast +from typing import Any, Callable, List, cast import attr diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index 93f3f3f742..5becda0545 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -1,7 +1,10 @@ """Helpers to help with integration platforms.""" +from __future__ import annotations + import asyncio +from collections.abc import Awaitable import logging -from typing import Any, Awaitable, Callable +from typing import Any, Callable from homeassistant.core import Event, HomeAssistant from homeassistant.loader import async_get_integration, bind_hass diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 6ed8a6b596..96cfbf0e1b 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -1,9 +1,10 @@ """Module to coordinate user intentions.""" from __future__ import annotations +from collections.abc import Iterable import logging import re -from typing import Any, Callable, Dict, Iterable +from typing import Any, Callable, Dict import voluptuous as vol diff --git a/homeassistant/helpers/location.py b/homeassistant/helpers/location.py index 597787ac17..da81040185 100644 --- a/homeassistant/helpers/location.py +++ b/homeassistant/helpers/location.py @@ -1,8 +1,8 @@ """Location helpers for Home Assistant.""" from __future__ import annotations +from collections.abc import Iterable import logging -from typing import Iterable import voluptuous as vol diff --git a/homeassistant/helpers/logging.py b/homeassistant/helpers/logging.py index a32d13ce51..e996e7cca1 100644 --- a/homeassistant/helpers/logging.py +++ b/homeassistant/helpers/logging.py @@ -1,9 +1,10 @@ """Helpers for logging allowing more advanced logging styles to be used.""" from __future__ import annotations +from collections.abc import Mapping, MutableMapping import inspect import logging -from typing import Any, Mapping, MutableMapping +from typing import Any class KeywordMessage: diff --git a/homeassistant/helpers/ratelimit.py b/homeassistant/helpers/ratelimit.py index fa671c6627..c34cfb72b3 100644 --- a/homeassistant/helpers/ratelimit.py +++ b/homeassistant/helpers/ratelimit.py @@ -2,9 +2,10 @@ from __future__ import annotations import asyncio +from collections.abc import Hashable from datetime import datetime, timedelta import logging -from typing import Any, Callable, Hashable +from typing import Any, Callable from homeassistant.core import HomeAssistant, callback import homeassistant.util.dt as dt_util diff --git a/homeassistant/helpers/reload.py b/homeassistant/helpers/reload.py index ef1d033cfa..01350b579c 100644 --- a/homeassistant/helpers/reload.py +++ b/homeassistant/helpers/reload.py @@ -2,8 +2,8 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import logging -from typing import Iterable from homeassistant import config as conf_util from homeassistant.const import SERVICE_RELOAD diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 12f75960c4..5a7fdcd176 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -2,13 +2,14 @@ from __future__ import annotations import asyncio +from collections.abc import Sequence from contextlib import asynccontextmanager, suppress from datetime import datetime, timedelta from functools import partial import itertools import logging from types import MappingProxyType -from typing import Any, Callable, Dict, Sequence, TypedDict, Union, cast +from typing import Any, Callable, Dict, TypedDict, Union, cast import async_timeout import voluptuous as vol diff --git a/homeassistant/helpers/script_variables.py b/homeassistant/helpers/script_variables.py index 86a700bc62..a72d0b5543 100644 --- a/homeassistant/helpers/script_variables.py +++ b/homeassistant/helpers/script_variables.py @@ -1,7 +1,8 @@ """Script variables.""" from __future__ import annotations -from typing import Any, Mapping +from collections.abc import Mapping +from typing import Any from homeassistant.core import HomeAssistant, callback diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 9dec919d4b..ed23926b0a 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable, Iterable import dataclasses from functools import partial, wraps import logging -from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable, TypedDict +from typing import TYPE_CHECKING, Any, Callable, TypedDict import voluptuous as vol diff --git a/homeassistant/helpers/state.py b/homeassistant/helpers/state.py index c9f267a89f..38647792b7 100644 --- a/homeassistant/helpers/state.py +++ b/homeassistant/helpers/state.py @@ -3,10 +3,11 @@ from __future__ import annotations import asyncio from collections import defaultdict +from collections.abc import Iterable import datetime as dt import logging from types import ModuleType, TracebackType -from typing import Any, Iterable +from typing import Any from homeassistant.components.sun import STATE_ABOVE_HORIZON, STATE_BELOW_HORIZON from homeassistant.const import ( diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 06fe5d288f..053ab2947d 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -5,6 +5,7 @@ from ast import literal_eval import asyncio import base64 import collections.abc +from collections.abc import Generator, Iterable from contextlib import suppress from contextvars import ContextVar from datetime import datetime, timedelta @@ -16,7 +17,7 @@ from operator import attrgetter import random import re import sys -from typing import Any, Callable, Generator, Iterable, cast +from typing import Any, Callable, cast from urllib.parse import urlencode as urllib_urlencode import weakref diff --git a/homeassistant/helpers/trace.py b/homeassistant/helpers/trace.py index 32e387d972..e2d5144f37 100644 --- a/homeassistant/helpers/trace.py +++ b/homeassistant/helpers/trace.py @@ -2,10 +2,11 @@ from __future__ import annotations from collections import deque +from collections.abc import Generator from contextlib import contextmanager from contextvars import ContextVar from functools import wraps -from typing import Any, Callable, Deque, Generator, cast +from typing import Any, Callable, cast from homeassistant.helpers.typing import TemplateVarsType import homeassistant.util.dt as dt_util @@ -76,7 +77,7 @@ class TraceElement: # Context variables for tracing # Current trace -trace_cv: ContextVar[dict[str, Deque[TraceElement]] | None] = ContextVar( +trace_cv: ContextVar[dict[str, deque[TraceElement]] | None] = ContextVar( "trace_cv", default=None ) # Stack of TraceElements @@ -168,7 +169,7 @@ def trace_append_element( trace[path].append(trace_element) -def trace_get(clear: bool = True) -> dict[str, Deque[TraceElement]] | None: +def trace_get(clear: bool = True) -> dict[str, deque[TraceElement]] | None: """Return the current trace.""" if clear: trace_clear() diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index d2d7612972..863fa71d43 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable from datetime import datetime, timedelta import logging from time import monotonic -from typing import Any, Awaitable, Callable, Generic, TypeVar +from typing import Any, Callable, Generic, TypeVar import urllib.error import aiohttp diff --git a/homeassistant/requirements.py b/homeassistant/requirements.py index aaad5c1f25..cc4ce32d80 100644 --- a/homeassistant/requirements.py +++ b/homeassistant/requirements.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Iterable import os -from typing import Any, Iterable, cast +from typing import Any, cast from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError diff --git a/homeassistant/scripts/__init__.py b/homeassistant/scripts/__init__.py index 9aa07b94dc..b31fc71817 100644 --- a/homeassistant/scripts/__init__.py +++ b/homeassistant/scripts/__init__.py @@ -3,11 +3,11 @@ from __future__ import annotations import argparse import asyncio +from collections.abc import Sequence import importlib import logging import os import sys -from typing import Sequence from homeassistant import runner from homeassistant.bootstrap import async_mount_local_lib_path diff --git a/homeassistant/setup.py b/homeassistant/setup.py index c1d4173fff..f5a6f9b972 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -2,11 +2,12 @@ from __future__ import annotations import asyncio +from collections.abc import Awaitable, Generator, Iterable import contextlib import logging.handlers from timeit import default_timer as timer from types import ModuleType -from typing import Awaitable, Callable, Generator, Iterable +from typing import Callable from homeassistant import config as conf_util, core, loader, requirements from homeassistant.config import async_notify_setup_error diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index c684d14d27..f7f0743455 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio +from collections.abc import Coroutine, Iterable, KeysView from datetime import datetime, timedelta import enum from functools import lru_cache, wraps @@ -11,7 +12,7 @@ import socket import string import threading from types import MappingProxyType -from typing import Any, Callable, Coroutine, Iterable, KeysView, TypeVar +from typing import Any, Callable, TypeVar import slugify as unicode_slug diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index 15353d1f7e..a467d54417 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -3,12 +3,13 @@ from __future__ import annotations from asyncio import Semaphore, coroutines, ensure_future, gather, get_running_loop from asyncio.events import AbstractEventLoop +from collections.abc import Awaitable, Coroutine import concurrent.futures import functools import logging import threading from traceback import extract_stack -from typing import Any, Awaitable, Callable, Coroutine, TypeVar +from typing import Any, Callable, TypeVar _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/util/logging.py b/homeassistant/util/logging.py index 1c0ff3de5d..dd3cb119c6 100644 --- a/homeassistant/util/logging.py +++ b/homeassistant/util/logging.py @@ -2,13 +2,14 @@ from __future__ import annotations import asyncio +from collections.abc import Coroutine from functools import partial, wraps import inspect import logging import logging.handlers import queue import traceback -from typing import Any, Awaitable, Callable, Coroutine, cast, overload +from typing import Any, Awaitable, Callable, cast, overload from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE from homeassistant.core import HomeAssistant, callback, is_callback diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index b03e93f17d..d63ddd6afa 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -2,11 +2,12 @@ from __future__ import annotations from collections import OrderedDict +from collections.abc import Iterator import fnmatch import logging import os from pathlib import Path -from typing import Any, Dict, Iterator, List, TextIO, TypeVar, Union, overload +from typing import Any, Dict, List, TextIO, TypeVar, Union, overload import yaml