diff --git a/homeassistant/components/alarm_control_panel/reproduce_state.py b/homeassistant/components/alarm_control_panel/reproduce_state.py index 90979d97dd0..e7e4c07b8ad 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 dfe51df7531..9c8cbd19810 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 ff716f3a83b..dd2ba824f8a 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 b422b2dcbe3..b5032af9326 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 3d3006638f9..50e051813c4 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 7183a3ebcf6..9c80a547f06 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 be52138e3e5..767a38b2e57 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 8fb15bd84e8..0ced9bad06d 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 3b82596a21c..c96b9ec5acc 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 799f07ed71b..d7e0f8510dd 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 4741dbdb7f5..12083a8d139 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 2614bd4228a..e1eb897f1ba 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 d1a4d236ebb..dc28e287f54 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 c9da43ebe3a..2d4244ec2dc 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 e8b17184bbe..8a51b210c5b 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 5af53768bc0..096108b460e 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 b45dd1ec5e3..26cc8e1c11c 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 ea21c147b9b..c99f098b222 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 ad2a074564c..884bbcde7c1 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 340596ff1ef..6fdf18df612 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 6e271bf60cd..b919db58345 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 09f459b32d6..35be51a99d9 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 d63912360a2..2768350c183 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 da218947457..0384c872d4c 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 3f73ebf4e0a..1303dee4518 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 ac2160120cc..f8d760c0a9f 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 5fe7e779a98..961345b7429 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 f996721eabd..230a0ed235c 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 a897aec2ba8..c198236789c 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 5ea7072e932..a2cb2cadd0b 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 ce1b7c12c46..56a03b0d133 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 47462f272d4..455fd877c0e 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 ca3f7b0f22a..63a8bd634d5 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 c45d057c3af..10f1be57be4 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 38680e15bf8..ca8ce74a52a 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 0eb62433734..26bd27baa75 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 ff08cdf411c..d845cb94676 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 f75f483b9fb..51951304f93 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 c52beaea2ef..fa8a33cc5bb 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 cc2f3c0a09c..1a29e7d8e12 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 68fac8aa5c9..fa70670eee7 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 0d575964b2b..e7e79f49be9 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 1707109197f..5d491a83ce1 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 f2d86067552..c77e41727a4 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 6cf8e7d7383..dc6caa93949 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 0d18b243520..71ea97bc371 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 6982a651a45..41e7d158c0c 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 4364dffe1e8..d628db825ca 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 5724175b4bb..021b996c945 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 05d52cf7830..071261e7b23 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 6741abbfc9f..f901600c98b 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 ecde6f67b67..94c54dd323d 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 b42a0bdc611..24f748d4a02 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 eed41fb1438..dd6e6766706 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 e17437db065..6ca5fe712b7 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 ea5b5666408..4e950651ab0 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 77ef913c629..d36739c9551 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 dd4c1e2928c..74eb253ebbb 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 76c168fbc38..da9e0fd090a 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 8fff4ebbdfa..66715edfe60 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 167f3a38edf..62b84b19099 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 de678f255fa..cba4439368b 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 2cd0b283cca..601e207a6f5 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 533d8f6476e..a7e2926036c 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 d8bcd455415..7b8364d9ba3 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 d827990ac55..2195c10cc1d 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 3ee458ec9db..8c7b61e96ec 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 b6e2897ade2..d9f74e5e776 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 01a8ca9ea6b..f5393078ab9 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 e2154810522..039090d3124 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 94fd836631b..4cc1ec1f693 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 2ad4863dbec..a7a92d3baf7 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 377f8a1dda2..3ab7d4815cf 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 eca22a56da8..e845f928068 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 7a1a3d4a06c..51e34017939 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 aafd9f51516..c116e64ca7f 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 38958bd4790..4d5a9baf46e 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 fcc501c2094..243ee4d7594 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 1cefd6af272..b84affe9e8d 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 3363178efe2..758636bee98 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 e667829bb10..a4442d2ae4b 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 eeec7e53a0a..bcd5ac214ee 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 93e1793da8d..72b061bd628 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 f55db8ce428..a97758d17f9 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 4675cdb8621..235eac5cd57 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 dd1bb333693..4e0ba257d59 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 283734f7578..cbb0e8563c5 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 d10707f4590..904d62639eb 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 12d9a6336c8..31e6220172a 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 6ef0bd9e665..3bd08e6f93e 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 989cc17f97d..6e9d4138621 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 eef4c56e379..8c2b2bddd67 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 7c600d98401..313d016935e 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 a815c75c8b3..cfe395773ad 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 f8fb12e1596..f38e4c2c695 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 9381c529187..c4bbca2567a 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 445151899ee..2e5fe935435 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 17ae01aa9b2..a7df9998f6a 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 362c93d04fa..958dcea555f 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 1356de0b572..3313da887c2 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 a081cfe3cc2..844fd369cac 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 a1964c432fc..a0642e8ead2 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 53b906efd35..0bb9a815c84 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 af568b40418..67d713e5087 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 248059f7f93..bfffb8523dd 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 18ef4c2082e..138fa81947c 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 891d6c7d28c..e19a065eb02 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 bbac18ab839..e0afbc49af2 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 705f48bbd70..8e7e57fa142 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 f30832479c2..e6af7751c88 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 46279fcb140..7ac221ea06e 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 ef45b8dcd97..abeeb40ca76 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 db16b3cc0b1..936464dc423 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 57dbb34c560..8f11fbf3116 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 ebde309de14..e026955f286 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 1a7e11ff5c9..b8a8db8f03d 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 93f3f3f7427..5becda0545b 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 6ed8a6b5968..96cfbf0e1b5 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 597787ac173..da81040185c 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 a32d13ce513..e996e7cca10 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 fa671c6627f..c34cfb72b36 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 ef1d033cfa7..01350b579c4 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 12f75960c41..5a7fdcd1767 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 86a700bc62b..a72d0b5543f 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 9dec919d4b5..ed23926b0a3 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 c9f267a89f5..38647792b7a 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 06fe5d288f5..053ab2947dd 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 32e387d972f..e2d5144f374 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 d2d7612972d..863fa71d43c 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 aaad5c1f251..cc4ce32d808 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 9aa07b94dc8..b31fc718173 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 c1d4173fff1..f5a6f9b9721 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 c684d14d276..f7f07434555 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 15353d1f7eb..a467d544174 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 1c0ff3de5d7..dd3cb119c6b 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 b03e93f17df..d63ddd6afa3 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