Update Union typing (5) [Py310] (#86428)
parent
8abce25948
commit
40be2324cc
|
@ -7,7 +7,7 @@ from enum import Enum
|
|||
from functools import wraps
|
||||
import logging
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Union, overload
|
||||
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypeAlias, overload
|
||||
|
||||
import voluptuous as vol
|
||||
import voluptuous_serialize
|
||||
|
@ -43,12 +43,13 @@ if TYPE_CHECKING:
|
|||
from .condition import DeviceAutomationConditionProtocol
|
||||
from .trigger import DeviceAutomationTriggerProtocol
|
||||
|
||||
DeviceAutomationPlatformType = Union[
|
||||
ModuleType,
|
||||
DeviceAutomationTriggerProtocol,
|
||||
DeviceAutomationConditionProtocol,
|
||||
DeviceAutomationActionProtocol,
|
||||
]
|
||||
DeviceAutomationPlatformType: TypeAlias = (
|
||||
ModuleType
|
||||
| DeviceAutomationTriggerProtocol
|
||||
| DeviceAutomationConditionProtocol
|
||||
| DeviceAutomationActionProtocol
|
||||
)
|
||||
|
||||
|
||||
DOMAIN = "device_automation"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for switch platform for Hue resources (V2 only)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any, TypeAlias
|
||||
|
||||
from aiohue.v2 import HueBridgeV2
|
||||
from aiohue.v2.controllers.events import EventType
|
||||
|
@ -22,9 +22,9 @@ from .bridge import HueBridge
|
|||
from .const import DOMAIN
|
||||
from .v2.entity import HueBaseEntity
|
||||
|
||||
ControllerType = Union[LightLevelController, MotionController]
|
||||
ControllerType: TypeAlias = LightLevelController | MotionController
|
||||
|
||||
SensingService = Union[LightLevel, Motion]
|
||||
SensingService: TypeAlias = LightLevel | Motion
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for Hue binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any, TypeAlias
|
||||
|
||||
from aiohue.v2 import HueBridgeV2
|
||||
from aiohue.v2.controllers.config import (
|
||||
|
@ -25,8 +25,8 @@ from ..bridge import HueBridge
|
|||
from ..const import DOMAIN
|
||||
from .entity import HueBaseEntity
|
||||
|
||||
SensorType = Union[Motion, EntertainmentConfiguration]
|
||||
ControllerType = Union[MotionController, EntertainmentConfigurationController]
|
||||
SensorType: TypeAlias = Motion | EntertainmentConfiguration
|
||||
ControllerType: TypeAlias = MotionController | EntertainmentConfigurationController
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Generic Hue Entity Model."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Union
|
||||
from typing import TYPE_CHECKING, TypeAlias
|
||||
|
||||
from aiohue.v2.controllers.base import BaseResourcesController
|
||||
from aiohue.v2.controllers.events import EventType
|
||||
|
@ -23,7 +23,7 @@ if TYPE_CHECKING:
|
|||
from aiohue.v2.models.light_level import LightLevel
|
||||
from aiohue.v2.models.motion import Motion
|
||||
|
||||
HueResource = Union[Light, DevicePower, GroupedLight, LightLevel, Motion]
|
||||
HueResource: TypeAlias = Light | DevicePower | GroupedLight | LightLevel | Motion
|
||||
|
||||
|
||||
RESOURCE_TYPE_NAMES = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for Hue sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any, TypeAlias
|
||||
|
||||
from aiohue.v2 import HueBridgeV2
|
||||
from aiohue.v2.controllers.events import EventType
|
||||
|
@ -32,13 +32,13 @@ from ..bridge import HueBridge
|
|||
from ..const import DOMAIN
|
||||
from .entity import HueBaseEntity
|
||||
|
||||
SensorType = Union[DevicePower, LightLevel, Temperature, ZigbeeConnectivity]
|
||||
ControllerType = Union[
|
||||
DevicePowerController,
|
||||
LightLevelController,
|
||||
TemperatureController,
|
||||
ZigbeeConnectivityController,
|
||||
]
|
||||
SensorType: TypeAlias = DevicePower | LightLevel | Temperature | ZigbeeConnectivity
|
||||
ControllerType: TypeAlias = (
|
||||
DevicePowerController
|
||||
| LightLevelController
|
||||
| TemperatureController
|
||||
| ZigbeeConnectivityController
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
|
@ -5,7 +5,7 @@ import asyncio
|
|||
from copy import deepcopy
|
||||
from itertools import chain
|
||||
import re
|
||||
from typing import Union, cast
|
||||
from typing import TypeAlias, cast
|
||||
|
||||
import pypck
|
||||
import voluptuous as vol
|
||||
|
@ -60,9 +60,10 @@ from .const import (
|
|||
|
||||
# typing
|
||||
AddressType = tuple[int, int, bool]
|
||||
DeviceConnectionType = Union[
|
||||
pypck.module.ModuleConnection, pypck.module.GroupConnection
|
||||
]
|
||||
DeviceConnectionType: TypeAlias = (
|
||||
pypck.module.ModuleConnection | pypck.module.GroupConnection
|
||||
)
|
||||
|
||||
InputType = type[pypck.inputs.Input]
|
||||
|
||||
# Regex for address validation
|
||||
|
|
Loading…
Reference in New Issue