diff --git a/homeassistant/components/knx/light.py b/homeassistant/components/knx/light.py index 0f8f2fe89af..c3e5f21cb3f 100644 --- a/homeassistant/components/knx/light.py +++ b/homeassistant/components/knx/light.py @@ -1,7 +1,7 @@ """Support for KNX/IP lights.""" from __future__ import annotations -from typing import Any, Tuple, cast +from typing import Any, cast from xknx import XKNX from xknx.devices.light import Light as XknxLight, XYYColor @@ -212,7 +212,7 @@ class KNXLight(KnxEntity, LightEntity): if not self._device.supports_brightness: # brightness will be calculated from color so color must not hold brightness again return cast( - Tuple[int, int, int], color_util.match_max_scale((255,), rgb) + tuple[int, int, int], color_util.match_max_scale((255,), rgb) ) return rgb return None @@ -226,7 +226,7 @@ class KNXLight(KnxEntity, LightEntity): if not self._device.supports_brightness: # brightness will be calculated from color so color must not hold brightness again return cast( - Tuple[int, int, int, int], + tuple[int, int, int, int], color_util.match_max_scale((255,), (*rgb, white)), ) return (*rgb, white) @@ -327,7 +327,7 @@ class KNXLight(KnxEntity, LightEntity): # normalize for brightness if brightness is derived from color brightness = self.brightness or 255 rgb = cast( - Tuple[int, int, int], + tuple[int, int, int], tuple(color * brightness // 255 for color in rgb), ) white = white * brightness // 255 if white is not None else None diff --git a/homeassistant/components/kraken/const.py b/homeassistant/components/kraken/const.py index 7382510efd0..ae626349cb0 100644 --- a/homeassistant/components/kraken/const.py +++ b/homeassistant/components/kraken/const.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Callable from dataclasses import dataclass -from typing import Dict, TypedDict +from typing import TypedDict from homeassistant.components.sensor import SensorEntityDescription from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -23,7 +23,7 @@ class KrakenResponseEntry(TypedDict): opening_price: float -KrakenResponse = Dict[str, KrakenResponseEntry] +KrakenResponse = dict[str, KrakenResponseEntry] DEFAULT_SCAN_INTERVAL = 60 diff --git a/homeassistant/components/lcn/helpers.py b/homeassistant/components/lcn/helpers.py index 43ea62cdf6e..0c8edd9b852 100644 --- a/homeassistant/components/lcn/helpers.py +++ b/homeassistant/components/lcn/helpers.py @@ -5,7 +5,7 @@ import asyncio from copy import deepcopy from itertools import chain import re -from typing import Tuple, Type, Union, cast +from typing import Union, cast import pypck import voluptuous as vol @@ -59,11 +59,11 @@ from .const import ( ) # typing -AddressType = Tuple[int, int, bool] +AddressType = tuple[int, int, bool] DeviceConnectionType = Union[ pypck.module.ModuleConnection, pypck.module.GroupConnection ] -InputType = Type[pypck.inputs.Input] +InputType = type[pypck.inputs.Input] # Regex for address validation PATTERN_ADDRESS = re.compile( diff --git a/homeassistant/components/motioneye/config_flow.py b/homeassistant/components/motioneye/config_flow.py index e90a6068ebc..84a6d0771e6 100644 --- a/homeassistant/components/motioneye/config_flow.py +++ b/homeassistant/components/motioneye/config_flow.py @@ -1,7 +1,7 @@ """Config flow for motionEye integration.""" from __future__ import annotations -from typing import Any, Dict, cast +from typing import Any, cast from motioneye_client.client import ( MotionEyeClientConnectionError, @@ -94,7 +94,7 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is None: return _get_form( - cast(Dict[str, Any], reauth_entry.data) if reauth_entry else {} + cast(dict[str, Any], reauth_entry.data) if reauth_entry else {} ) if self._hassio_discovery: diff --git a/homeassistant/components/motioneye/media_source.py b/homeassistant/components/motioneye/media_source.py index a24c9e7ab26..8c7b86ca173 100644 --- a/homeassistant/components/motioneye/media_source.py +++ b/homeassistant/components/motioneye/media_source.py @@ -3,7 +3,7 @@ from __future__ import annotations import logging from pathlib import PurePath -from typing import Optional, Tuple, cast +from typing import Optional, cast from motioneye_client.const import KEY_MEDIA_LIST, KEY_MIME_TYPE, KEY_PATH @@ -96,7 +96,7 @@ class MotionEyeMediaSource(MediaSource): base = [None] * 4 data = identifier.split("#", 3) return cast( - Tuple[Optional[str], Optional[str], Optional[str], Optional[str]], + tuple[Optional[str], Optional[str], Optional[str], Optional[str]], tuple(data + base)[:4], # type: ignore[operator] ) diff --git a/homeassistant/components/mysensors/const.py b/homeassistant/components/mysensors/const.py index 9ad7aa3c084..ad25e601bbd 100644 --- a/homeassistant/components/mysensors/const.py +++ b/homeassistant/components/mysensors/const.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections import defaultdict -from typing import Final, Literal, Tuple, TypedDict +from typing import Final, Literal, TypedDict from homeassistant.const import Platform @@ -65,7 +65,7 @@ GatewayId = str # # Gateway may be fetched by giving the gateway id to get_mysensors_gateway() -DevId = Tuple[GatewayId, int, int, int] +DevId = tuple[GatewayId, int, int, int] # describes the backend of a hass entity. Contents are: GatewayId, node_id, child_id, v_type as int # # The string version of v_type can be looked up in the enum gateway.const.SetReq of the appropriate BaseAsyncGateway diff --git a/homeassistant/components/mysensors/light.py b/homeassistant/components/mysensors/light.py index 1fbce6bbfa0..870cde863c4 100644 --- a/homeassistant/components/mysensors/light.py +++ b/homeassistant/components/mysensors/light.py @@ -1,7 +1,7 @@ """Support for MySensors lights.""" from __future__ import annotations -from typing import Any, Tuple, cast +from typing import Any, cast from homeassistant.components import mysensors from homeassistant.components.light import ( @@ -195,7 +195,7 @@ class MySensorsLightRGB(MySensorsLight): """Update the controller with values from RGB child.""" value = self._values[self.value_type] self._attr_rgb_color = cast( - Tuple[int, int, int], tuple(rgb_hex_to_rgb_list(value)) + tuple[int, int, int], tuple(rgb_hex_to_rgb_list(value)) ) @@ -234,5 +234,5 @@ class MySensorsLightRGBW(MySensorsLightRGB): """Update the controller with values from RGBW child.""" value = self._values[self.value_type] self._attr_rgbw_color = cast( - Tuple[int, int, int, int], tuple(rgb_hex_to_rgb_list(value)) + tuple[int, int, int, int], tuple(rgb_hex_to_rgb_list(value)) ) diff --git a/homeassistant/components/overkiz/const.py b/homeassistant/components/overkiz/const.py index 5d29358c3f4..0082890abf9 100644 --- a/homeassistant/components/overkiz/const.py +++ b/homeassistant/components/overkiz/const.py @@ -2,7 +2,7 @@ from __future__ import annotations from datetime import timedelta -from typing import Any, Dict, Final, List, Union +from typing import Any, Final, Union from pyoverkiz.enums import UIClass from pyoverkiz.enums.ui import UIWidget @@ -38,4 +38,4 @@ OVERKIZ_DEVICE_TO_PLATFORM: dict[UIClass | UIWidget, Platform] = { UIClass.LIGHT: Platform.LIGHT, } -OverkizStateType = Union[str, int, float, bool, Dict[Any, Any], List[Any], None] +OverkizStateType = Union[str, int, float, bool, dict[Any, Any], list[Any], None] diff --git a/homeassistant/components/overkiz/coordinator.py b/homeassistant/components/overkiz/coordinator.py index d0d1baadff0..54cc6aa74ce 100644 --- a/homeassistant/components/overkiz/coordinator.py +++ b/homeassistant/components/overkiz/coordinator.py @@ -5,7 +5,7 @@ from collections.abc import Callable from datetime import timedelta import json import logging -from typing import Any, Dict +from typing import Any from aiohttp import ServerDisconnectedError from pyoverkiz.client import OverkizClient @@ -37,7 +37,7 @@ DATA_TYPE_TO_PYTHON: dict[DataType, Callable[[Any], OverkizStateType]] = { _LOGGER = logging.getLogger(__name__) -class OverkizDataUpdateCoordinator(DataUpdateCoordinator[Dict[str, Device]]): +class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]): """Class to manage fetching data from Overkiz platform.""" def __init__( diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index 991769bd5c4..6ae8ba41de5 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio import logging -from typing import Any, Dict, cast +from typing import Any, cast import voluptuous as vol from voluptuous.humanize import humanize_error @@ -244,7 +244,7 @@ async def _async_process_config(hass, config, component) -> bool: try: raw_config = blueprint_inputs.async_substitute() config_block = cast( - Dict[str, Any], + dict[str, Any], await async_validate_config_item(hass, raw_config), ) except vol.Invalid as err: diff --git a/homeassistant/components/tractive/__init__.py b/homeassistant/components/tractive/__init__.py index 496ae3a85d0..99b47559d80 100644 --- a/homeassistant/components/tractive/__init__.py +++ b/homeassistant/components/tractive/__init__.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio from dataclasses import dataclass import logging -from typing import Any, List, cast +from typing import Any, cast import aiotractive @@ -164,7 +164,7 @@ class TractiveClient: ) -> list[aiotractive.trackable_object.TrackableObject]: """Get list of trackable objects.""" return cast( - List[aiotractive.trackable_object.TrackableObject], + list[aiotractive.trackable_object.TrackableObject], await self._client.trackable_objects(), ) diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index 5b3bde9bc73..a7ab7139aa0 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -10,7 +10,7 @@ import logging import mimetypes import os import re -from typing import Optional, Tuple, cast +from typing import Optional, cast from aiohttp import web import mutagen @@ -46,7 +46,7 @@ from homeassistant.util.yaml import load_yaml _LOGGER = logging.getLogger(__name__) -TtsAudioType = Tuple[Optional[str], Optional[bytes]] +TtsAudioType = tuple[Optional[str], Optional[bytes]] ATTR_CACHE = "cache" ATTR_LANGUAGE = "language"