Update typing (3) [k-t] (#63924)
This commit is contained in:
parent
bcb93d95bb
commit
fa7e787415
12 changed files with 28 additions and 28 deletions
|
@ -1,7 +1,7 @@
|
||||||
"""Support for KNX/IP lights."""
|
"""Support for KNX/IP lights."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Tuple, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from xknx import XKNX
|
from xknx import XKNX
|
||||||
from xknx.devices.light import Light as XknxLight, XYYColor
|
from xknx.devices.light import Light as XknxLight, XYYColor
|
||||||
|
@ -212,7 +212,7 @@ class KNXLight(KnxEntity, LightEntity):
|
||||||
if not self._device.supports_brightness:
|
if not self._device.supports_brightness:
|
||||||
# brightness will be calculated from color so color must not hold brightness again
|
# brightness will be calculated from color so color must not hold brightness again
|
||||||
return cast(
|
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 rgb
|
||||||
return None
|
return None
|
||||||
|
@ -226,7 +226,7 @@ class KNXLight(KnxEntity, LightEntity):
|
||||||
if not self._device.supports_brightness:
|
if not self._device.supports_brightness:
|
||||||
# brightness will be calculated from color so color must not hold brightness again
|
# brightness will be calculated from color so color must not hold brightness again
|
||||||
return cast(
|
return cast(
|
||||||
Tuple[int, int, int, int],
|
tuple[int, int, int, int],
|
||||||
color_util.match_max_scale((255,), (*rgb, white)),
|
color_util.match_max_scale((255,), (*rgb, white)),
|
||||||
)
|
)
|
||||||
return (*rgb, white)
|
return (*rgb, white)
|
||||||
|
@ -327,7 +327,7 @@ class KNXLight(KnxEntity, LightEntity):
|
||||||
# normalize for brightness if brightness is derived from color
|
# normalize for brightness if brightness is derived from color
|
||||||
brightness = self.brightness or 255
|
brightness = self.brightness or 255
|
||||||
rgb = cast(
|
rgb = cast(
|
||||||
Tuple[int, int, int],
|
tuple[int, int, int],
|
||||||
tuple(color * brightness // 255 for color in rgb),
|
tuple(color * brightness // 255 for color in rgb),
|
||||||
)
|
)
|
||||||
white = white * brightness // 255 if white is not None else None
|
white = white * brightness // 255 if white is not None else None
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Dict, TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
@ -23,7 +23,7 @@ class KrakenResponseEntry(TypedDict):
|
||||||
opening_price: float
|
opening_price: float
|
||||||
|
|
||||||
|
|
||||||
KrakenResponse = Dict[str, KrakenResponseEntry]
|
KrakenResponse = dict[str, KrakenResponseEntry]
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SCAN_INTERVAL = 60
|
DEFAULT_SCAN_INTERVAL = 60
|
||||||
|
|
|
@ -5,7 +5,7 @@ import asyncio
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import re
|
import re
|
||||||
from typing import Tuple, Type, Union, cast
|
from typing import Union, cast
|
||||||
|
|
||||||
import pypck
|
import pypck
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -59,11 +59,11 @@ from .const import (
|
||||||
)
|
)
|
||||||
|
|
||||||
# typing
|
# typing
|
||||||
AddressType = Tuple[int, int, bool]
|
AddressType = tuple[int, int, bool]
|
||||||
DeviceConnectionType = Union[
|
DeviceConnectionType = Union[
|
||||||
pypck.module.ModuleConnection, pypck.module.GroupConnection
|
pypck.module.ModuleConnection, pypck.module.GroupConnection
|
||||||
]
|
]
|
||||||
InputType = Type[pypck.inputs.Input]
|
InputType = type[pypck.inputs.Input]
|
||||||
|
|
||||||
# Regex for address validation
|
# Regex for address validation
|
||||||
PATTERN_ADDRESS = re.compile(
|
PATTERN_ADDRESS = re.compile(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Config flow for motionEye integration."""
|
"""Config flow for motionEye integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from motioneye_client.client import (
|
from motioneye_client.client import (
|
||||||
MotionEyeClientConnectionError,
|
MotionEyeClientConnectionError,
|
||||||
|
@ -94,7 +94,7 @@ class MotionEyeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return _get_form(
|
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:
|
if self._hassio_discovery:
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import PurePath
|
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
|
from motioneye_client.const import KEY_MEDIA_LIST, KEY_MIME_TYPE, KEY_PATH
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class MotionEyeMediaSource(MediaSource):
|
||||||
base = [None] * 4
|
base = [None] * 4
|
||||||
data = identifier.split("#", 3)
|
data = identifier.split("#", 3)
|
||||||
return cast(
|
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]
|
tuple(data + base)[:4], # type: ignore[operator]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Final, Literal, Tuple, TypedDict
|
from typing import Final, Literal, TypedDict
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ GatewayId = str
|
||||||
#
|
#
|
||||||
# Gateway may be fetched by giving the gateway id to get_mysensors_gateway()
|
# 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
|
# 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
|
# The string version of v_type can be looked up in the enum gateway.const.SetReq of the appropriate BaseAsyncGateway
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for MySensors lights."""
|
"""Support for MySensors lights."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Tuple, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from homeassistant.components import mysensors
|
from homeassistant.components import mysensors
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
|
@ -195,7 +195,7 @@ class MySensorsLightRGB(MySensorsLight):
|
||||||
"""Update the controller with values from RGB child."""
|
"""Update the controller with values from RGB child."""
|
||||||
value = self._values[self.value_type]
|
value = self._values[self.value_type]
|
||||||
self._attr_rgb_color = cast(
|
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."""
|
"""Update the controller with values from RGBW child."""
|
||||||
value = self._values[self.value_type]
|
value = self._values[self.value_type]
|
||||||
self._attr_rgbw_color = cast(
|
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))
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
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 import UIClass
|
||||||
from pyoverkiz.enums.ui import UIWidget
|
from pyoverkiz.enums.ui import UIWidget
|
||||||
|
@ -38,4 +38,4 @@ OVERKIZ_DEVICE_TO_PLATFORM: dict[UIClass | UIWidget, Platform] = {
|
||||||
UIClass.LIGHT: Platform.LIGHT,
|
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]
|
||||||
|
|
|
@ -5,7 +5,7 @@ from collections.abc import Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import ServerDisconnectedError
|
from aiohttp import ServerDisconnectedError
|
||||||
from pyoverkiz.client import OverkizClient
|
from pyoverkiz.client import OverkizClient
|
||||||
|
@ -37,7 +37,7 @@ DATA_TYPE_TO_PYTHON: dict[DataType, Callable[[Any], OverkizStateType]] = {
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OverkizDataUpdateCoordinator(DataUpdateCoordinator[Dict[str, Device]]):
|
class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]):
|
||||||
"""Class to manage fetching data from Overkiz platform."""
|
"""Class to manage fetching data from Overkiz platform."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from voluptuous.humanize import humanize_error
|
from voluptuous.humanize import humanize_error
|
||||||
|
@ -244,7 +244,7 @@ async def _async_process_config(hass, config, component) -> bool:
|
||||||
try:
|
try:
|
||||||
raw_config = blueprint_inputs.async_substitute()
|
raw_config = blueprint_inputs.async_substitute()
|
||||||
config_block = cast(
|
config_block = cast(
|
||||||
Dict[str, Any],
|
dict[str, Any],
|
||||||
await async_validate_config_item(hass, raw_config),
|
await async_validate_config_item(hass, raw_config),
|
||||||
)
|
)
|
||||||
except vol.Invalid as err:
|
except vol.Invalid as err:
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, List, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import aiotractive
|
import aiotractive
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class TractiveClient:
|
||||||
) -> list[aiotractive.trackable_object.TrackableObject]:
|
) -> list[aiotractive.trackable_object.TrackableObject]:
|
||||||
"""Get list of trackable objects."""
|
"""Get list of trackable objects."""
|
||||||
return cast(
|
return cast(
|
||||||
List[aiotractive.trackable_object.TrackableObject],
|
list[aiotractive.trackable_object.TrackableObject],
|
||||||
await self._client.trackable_objects(),
|
await self._client.trackable_objects(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import logging
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from typing import Optional, Tuple, cast
|
from typing import Optional, cast
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import mutagen
|
import mutagen
|
||||||
|
@ -46,7 +46,7 @@ from homeassistant.util.yaml import load_yaml
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TtsAudioType = Tuple[Optional[str], Optional[bytes]]
|
TtsAudioType = tuple[Optional[str], Optional[bytes]]
|
||||||
|
|
||||||
ATTR_CACHE = "cache"
|
ATTR_CACHE = "cache"
|
||||||
ATTR_LANGUAGE = "language"
|
ATTR_LANGUAGE = "language"
|
||||||
|
|
Loading…
Add table
Reference in a new issue