Update Union typing (5) [Py310] (#86428)
This commit is contained in:
parent
8abce25948
commit
40be2324cc
6 changed files with 29 additions and 27 deletions
|
@ -7,7 +7,7 @@ from enum import Enum
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import logging
|
import logging
|
||||||
from types import ModuleType
|
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 as vol
|
||||||
import voluptuous_serialize
|
import voluptuous_serialize
|
||||||
|
@ -43,12 +43,13 @@ if TYPE_CHECKING:
|
||||||
from .condition import DeviceAutomationConditionProtocol
|
from .condition import DeviceAutomationConditionProtocol
|
||||||
from .trigger import DeviceAutomationTriggerProtocol
|
from .trigger import DeviceAutomationTriggerProtocol
|
||||||
|
|
||||||
DeviceAutomationPlatformType = Union[
|
DeviceAutomationPlatformType: TypeAlias = (
|
||||||
ModuleType,
|
ModuleType
|
||||||
DeviceAutomationTriggerProtocol,
|
| DeviceAutomationTriggerProtocol
|
||||||
DeviceAutomationConditionProtocol,
|
| DeviceAutomationConditionProtocol
|
||||||
DeviceAutomationActionProtocol,
|
| DeviceAutomationActionProtocol
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
||||||
DOMAIN = "device_automation"
|
DOMAIN = "device_automation"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for switch platform for Hue resources (V2 only)."""
|
"""Support for switch platform for Hue resources (V2 only)."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, TypeAlias
|
||||||
|
|
||||||
from aiohue.v2 import HueBridgeV2
|
from aiohue.v2 import HueBridgeV2
|
||||||
from aiohue.v2.controllers.events import EventType
|
from aiohue.v2.controllers.events import EventType
|
||||||
|
@ -22,9 +22,9 @@ from .bridge import HueBridge
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .v2.entity import HueBaseEntity
|
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(
|
async def async_setup_entry(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Hue binary sensors."""
|
"""Support for Hue binary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, TypeAlias
|
||||||
|
|
||||||
from aiohue.v2 import HueBridgeV2
|
from aiohue.v2 import HueBridgeV2
|
||||||
from aiohue.v2.controllers.config import (
|
from aiohue.v2.controllers.config import (
|
||||||
|
@ -25,8 +25,8 @@ from ..bridge import HueBridge
|
||||||
from ..const import DOMAIN
|
from ..const import DOMAIN
|
||||||
from .entity import HueBaseEntity
|
from .entity import HueBaseEntity
|
||||||
|
|
||||||
SensorType = Union[Motion, EntertainmentConfiguration]
|
SensorType: TypeAlias = Motion | EntertainmentConfiguration
|
||||||
ControllerType = Union[MotionController, EntertainmentConfigurationController]
|
ControllerType: TypeAlias = MotionController | EntertainmentConfigurationController
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Generic Hue Entity Model."""
|
"""Generic Hue Entity Model."""
|
||||||
from __future__ import annotations
|
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.base import BaseResourcesController
|
||||||
from aiohue.v2.controllers.events import EventType
|
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.light_level import LightLevel
|
||||||
from aiohue.v2.models.motion import Motion
|
from aiohue.v2.models.motion import Motion
|
||||||
|
|
||||||
HueResource = Union[Light, DevicePower, GroupedLight, LightLevel, Motion]
|
HueResource: TypeAlias = Light | DevicePower | GroupedLight | LightLevel | Motion
|
||||||
|
|
||||||
|
|
||||||
RESOURCE_TYPE_NAMES = {
|
RESOURCE_TYPE_NAMES = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Hue sensors."""
|
"""Support for Hue sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, TypeAlias
|
||||||
|
|
||||||
from aiohue.v2 import HueBridgeV2
|
from aiohue.v2 import HueBridgeV2
|
||||||
from aiohue.v2.controllers.events import EventType
|
from aiohue.v2.controllers.events import EventType
|
||||||
|
@ -32,13 +32,13 @@ from ..bridge import HueBridge
|
||||||
from ..const import DOMAIN
|
from ..const import DOMAIN
|
||||||
from .entity import HueBaseEntity
|
from .entity import HueBaseEntity
|
||||||
|
|
||||||
SensorType = Union[DevicePower, LightLevel, Temperature, ZigbeeConnectivity]
|
SensorType: TypeAlias = DevicePower | LightLevel | Temperature | ZigbeeConnectivity
|
||||||
ControllerType = Union[
|
ControllerType: TypeAlias = (
|
||||||
DevicePowerController,
|
DevicePowerController
|
||||||
LightLevelController,
|
| LightLevelController
|
||||||
TemperatureController,
|
| TemperatureController
|
||||||
ZigbeeConnectivityController,
|
| ZigbeeConnectivityController
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
|
|
@ -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 Union, cast
|
from typing import TypeAlias, cast
|
||||||
|
|
||||||
import pypck
|
import pypck
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -60,9 +60,10 @@ from .const import (
|
||||||
|
|
||||||
# typing
|
# typing
|
||||||
AddressType = tuple[int, int, bool]
|
AddressType = tuple[int, int, bool]
|
||||||
DeviceConnectionType = Union[
|
DeviceConnectionType: TypeAlias = (
|
||||||
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue