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