Update Union typing (1) [Py310] (#86424)
This commit is contained in:
parent
d7dda6bee5
commit
1eec87214f
9 changed files with 30 additions and 45 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generic, TypeVar, Union
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from pydeconz.models.deconz_device import DeconzDevice as PydeconzDevice
|
||||
from pydeconz.models.group import Group as PydeconzGroup
|
||||
|
@ -21,12 +21,7 @@ from .util import serial_from_unique_id
|
|||
|
||||
_DeviceT = TypeVar(
|
||||
"_DeviceT",
|
||||
bound=Union[
|
||||
PydeconzGroup,
|
||||
PydeconzLightBase,
|
||||
PydeconzSensorBase,
|
||||
PydeconzScene,
|
||||
],
|
||||
bound=PydeconzGroup | PydeconzLightBase | PydeconzSensorBase | PydeconzScene,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for deCONZ lights."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, TypedDict, TypeVar, Union
|
||||
from typing import Any, TypedDict, TypeVar
|
||||
|
||||
from pydeconz.interfaces.groups import GroupHandler
|
||||
from pydeconz.interfaces.lights import LightHandler
|
||||
|
@ -47,7 +47,7 @@ DECONZ_TO_COLOR_MODE = {
|
|||
LightColorMode.XY: ColorMode.XY,
|
||||
}
|
||||
|
||||
_LightDeviceT = TypeVar("_LightDeviceT", bound=Union[Group, Light])
|
||||
_LightDeviceT = TypeVar("_LightDeviceT", bound=Group | Light)
|
||||
|
||||
|
||||
class SetStateAttributes(TypedDict, total=False):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
|
||||
from pydeconz.models.event import EventType
|
||||
from pydeconz.models.light.lock import Lock
|
||||
|
@ -50,7 +50,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class DeconzLock(DeconzDevice[Union[DoorLock, Lock]], LockEntity):
|
||||
class DeconzLock(DeconzDevice[DoorLock | Lock], LockEntity):
|
||||
"""Representation of a deCONZ lock."""
|
||||
|
||||
TYPE = DOMAIN
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Generic platform."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypeVar, Union
|
||||
from typing import TypeVar
|
||||
|
||||
from devolo_plc_api.device import Device
|
||||
from devolo_plc_api.device_api import (
|
||||
|
@ -22,13 +22,13 @@ from .const import DOMAIN
|
|||
|
||||
_DataT = TypeVar(
|
||||
"_DataT",
|
||||
bound=Union[
|
||||
LogicalNetwork,
|
||||
list[ConnectedStationInfo],
|
||||
list[NeighborAPInfo],
|
||||
WifiGuestAccessGet,
|
||||
bool,
|
||||
],
|
||||
bound=(
|
||||
LogicalNetwork
|
||||
| list[ConnectedStationInfo]
|
||||
| list[NeighborAPInfo]
|
||||
| WifiGuestAccessGet
|
||||
| bool
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic, TypeVar, Union
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
from devolo_plc_api.device import Device
|
||||
from devolo_plc_api.device_api import ConnectedStationInfo, NeighborAPInfo
|
||||
|
@ -30,11 +30,7 @@ from .entity import DevoloEntity
|
|||
|
||||
_DataT = TypeVar(
|
||||
"_DataT",
|
||||
bound=Union[
|
||||
LogicalNetwork,
|
||||
list[ConnectedStationInfo],
|
||||
list[NeighborAPInfo],
|
||||
],
|
||||
bound=LogicalNetwork | list[ConnectedStationInfo] | list[NeighborAPInfo],
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic, TypeVar, Union
|
||||
from typing import Any, Generic, TypeVar
|
||||
|
||||
from devolo_plc_api.device import Device
|
||||
from devolo_plc_api.device_api import WifiGuestAccessGet
|
||||
|
@ -19,13 +19,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
|||
from .const import DOMAIN, SWITCH_GUEST_WIFI, SWITCH_LEDS
|
||||
from .entity import DevoloEntity
|
||||
|
||||
_DataT = TypeVar(
|
||||
"_DataT",
|
||||
bound=Union[
|
||||
WifiGuestAccessGet,
|
||||
bool,
|
||||
],
|
||||
)
|
||||
_DataT = TypeVar("_DataT", bound=WifiGuestAccessGet | bool)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
from typing import Literal, Union
|
||||
from typing import Literal
|
||||
|
||||
from pymata_express.pymata_express import PymataExpress
|
||||
from pymata_express.pymata_express_serial import serial
|
||||
|
@ -29,7 +29,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
FirmataPinType = Union[int, str]
|
||||
FirmataPinType = int | str
|
||||
|
||||
|
||||
class FirmataBoard:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Platform for shared base classes for sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypeVar, Union
|
||||
from typing import TypeVar
|
||||
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
@ -15,11 +15,11 @@ from .coordinator import (
|
|||
|
||||
_FlumeCoordinatorT = TypeVar(
|
||||
"_FlumeCoordinatorT",
|
||||
bound=Union[
|
||||
FlumeDeviceDataUpdateCoordinator,
|
||||
FlumeDeviceConnectionUpdateCoordinator,
|
||||
FlumeNotificationDataUpdateCoordinator,
|
||||
],
|
||||
bound=(
|
||||
FlumeDeviceDataUpdateCoordinator
|
||||
| FlumeDeviceConnectionUpdateCoordinator
|
||||
| FlumeNotificationDataUpdateCoordinator
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Sequence
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Union, cast
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
from urllib.parse import quote, unquote
|
||||
|
||||
from homeassistant.components.media_player import BrowseMedia, MediaClass, MediaType
|
||||
|
@ -160,7 +160,7 @@ async def get_owntone_content(
|
|||
return create_browse_media_response(
|
||||
master,
|
||||
media_content,
|
||||
cast(list[dict[str, Union[int, str]]], result),
|
||||
cast(list[dict[str, int | str]], result),
|
||||
children,
|
||||
)
|
||||
if media_content.id_or_path == "": # top level search
|
||||
|
@ -188,7 +188,7 @@ async def get_owntone_content(
|
|||
return create_browse_media_response(
|
||||
master,
|
||||
media_content,
|
||||
cast(list[dict[str, Union[int, str]]], result),
|
||||
cast(list[dict[str, int | str]], result),
|
||||
)
|
||||
# Not a directory or top level of library
|
||||
# We should have content type and id
|
||||
|
@ -214,7 +214,7 @@ async def get_owntone_content(
|
|||
)
|
||||
|
||||
return create_browse_media_response(
|
||||
master, media_content, cast(list[dict[str, Union[int, str]]], result)
|
||||
master, media_content, cast(list[dict[str, int | str]], result)
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue