Update typing (3) [k-t] (#63924)

This commit is contained in:
Marc Mueller 2022-01-11 21:26:55 +01:00 committed by GitHub
parent bcb93d95bb
commit fa7e787415
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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:

View file

@ -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]
)

View file

@ -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

View file

@ -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))
)

View file

@ -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]

View file

@ -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__(

View file

@ -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:

View file

@ -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(),
)

View file

@ -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"