mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Update Union typing (2) [Py310] (#86425)
This commit is contained in:
parent
1eec87214f
commit
f57c0ea725
@ -6,7 +6,7 @@ import asyncio
|
||||
from collections.abc import Iterable
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Any, Union, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from gcal_sync.api import (
|
||||
GoogleCalendarService,
|
||||
@ -392,9 +392,7 @@ class CalendarQueryUpdateCoordinator(DataUpdateCoordinator[list[Event]]):
|
||||
|
||||
|
||||
class GoogleCalendarEntity(
|
||||
CoordinatorEntity[
|
||||
Union[CalendarSyncUpdateCoordinator, CalendarQueryUpdateCoordinator]
|
||||
],
|
||||
CoordinatorEntity[CalendarSyncUpdateCoordinator | CalendarQueryUpdateCoordinator],
|
||||
CalendarEntity,
|
||||
):
|
||||
"""A calendar event entity."""
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Support for the sensors in a GreenEye Monitor."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
|
||||
import greeneye
|
||||
|
||||
@ -116,12 +116,12 @@ async def async_setup_platform(
|
||||
on_new_monitor(monitor)
|
||||
|
||||
|
||||
UnderlyingSensorType = Union[
|
||||
greeneye.monitor.Channel,
|
||||
greeneye.monitor.PulseCounter,
|
||||
greeneye.monitor.TemperatureSensor,
|
||||
greeneye.monitor.VoltageSensor,
|
||||
]
|
||||
UnderlyingSensorType = (
|
||||
greeneye.monitor.Channel
|
||||
| greeneye.monitor.PulseCounter
|
||||
| greeneye.monitor.TemperatureSensor
|
||||
| greeneye.monitor.VoltageSensor
|
||||
)
|
||||
|
||||
|
||||
class GEMSensor(SensorEntity):
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import timedelta
|
||||
from typing import Any, TypeVar, Union
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from jellyfin_apiclient_python import JellyfinClient
|
||||
|
||||
@ -15,10 +15,7 @@ from .const import DOMAIN, LOGGER
|
||||
|
||||
JellyfinDataT = TypeVar(
|
||||
"JellyfinDataT",
|
||||
bound=Union[
|
||||
dict[str, dict[str, Any]],
|
||||
dict[str, Any],
|
||||
],
|
||||
bound=dict[str, dict[str, Any]] | dict[str, Any],
|
||||
)
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import timedelta
|
||||
from typing import Generic, TypeVar, Union, cast
|
||||
from typing import Generic, TypeVar, cast
|
||||
|
||||
from aiopyarr import LidarrAlbum, LidarrQueue, LidarrRootFolder, exceptions
|
||||
from aiopyarr.lidarr_client import LidarrClient
|
||||
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
|
||||
from .const import DEFAULT_MAX_RECORDS, DOMAIN, LOGGER
|
||||
|
||||
T = TypeVar("T", bound=Union[list[LidarrRootFolder], LidarrQueue, str, LidarrAlbum])
|
||||
T = TypeVar("T", bound=list[LidarrRootFolder] | LidarrQueue | str | LidarrAlbum)
|
||||
|
||||
|
||||
class LidarrDataUpdateCoordinator(DataUpdateCoordinator[T], Generic[T], ABC):
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Any, Generic, Union, cast
|
||||
from typing import Any, Generic, cast
|
||||
|
||||
from pylitterbot import FeederRobot, LitterRobot, LitterRobot4, Robot
|
||||
|
||||
@ -55,7 +55,7 @@ class LitterRobotSensorEntity(LitterRobotEntity[_RobotT], SensorEntity):
|
||||
if self.entity_description.should_report(self.robot):
|
||||
if isinstance(val := getattr(self.robot, self.entity_description.key), str):
|
||||
return val.lower()
|
||||
return cast(Union[float, datetime, None], val)
|
||||
return cast(float | datetime | None, val)
|
||||
return None
|
||||
|
||||
@property
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Coroutine
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Generic, Union
|
||||
from typing import Any, Generic
|
||||
|
||||
from pylitterbot import FeederRobot, LitterRobot
|
||||
|
||||
@ -34,13 +34,13 @@ class RobotSwitchEntityDescription(SwitchEntityDescription, RequiredKeysMixin[_R
|
||||
|
||||
|
||||
ROBOT_SWITCHES = [
|
||||
RobotSwitchEntityDescription[Union[LitterRobot, FeederRobot]](
|
||||
RobotSwitchEntityDescription[LitterRobot | FeederRobot](
|
||||
key="night_light_mode_enabled",
|
||||
name="Night light mode",
|
||||
icons=("mdi:lightbulb-on", "mdi:lightbulb-off"),
|
||||
set_fn=lambda robot, value: robot.set_night_light(value),
|
||||
),
|
||||
RobotSwitchEntityDescription[Union[LitterRobot, FeederRobot]](
|
||||
RobotSwitchEntityDescription[LitterRobot | FeederRobot](
|
||||
key="panel_lock_enabled",
|
||||
name="Panel lockout",
|
||||
icons=("mdi:lock", "mdi:lock-open"),
|
||||
|
@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, TypeVar, Union
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from meteofrance_api.helpers import (
|
||||
get_warning_text_status_from_indice_color,
|
||||
@ -49,7 +49,7 @@ from .const import (
|
||||
MODEL,
|
||||
)
|
||||
|
||||
_DataT = TypeVar("_DataT", bound=Union[Rain, Forecast, CurrentPhenomenons])
|
||||
_DataT = TypeVar("_DataT", bound=Rain | Forecast | CurrentPhenomenons)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import timedelta
|
||||
from typing import Generic, TypeVar, Union, cast
|
||||
from typing import Generic, TypeVar, cast
|
||||
|
||||
from aiopyarr import Health, RadarrMovie, RootFolder, SystemStatus, exceptions
|
||||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
||||
T = TypeVar("T", bound=Union[SystemStatus, list[RootFolder], list[Health], int])
|
||||
T = TypeVar("T", bound=SystemStatus | list[RootFolder] | list[Health] | int)
|
||||
|
||||
|
||||
class RadarrDataUpdateCoordinator(DataUpdateCoordinator[T], Generic[T], ABC):
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Coroutine
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Final, Generic, TypeVar, Union
|
||||
from typing import Any, Final, Generic, TypeVar
|
||||
|
||||
from homeassistant.components.button import (
|
||||
ButtonDeviceClass,
|
||||
@ -23,7 +23,7 @@ from .coordinator import ShellyBlockCoordinator, ShellyRpcCoordinator, get_entry
|
||||
from .utils import get_block_device_name, get_device_entry_gen, get_rpc_device_name
|
||||
|
||||
_ShellyCoordinatorT = TypeVar(
|
||||
"_ShellyCoordinatorT", bound=Union[ShellyBlockCoordinator, ShellyRpcCoordinator]
|
||||
"_ShellyCoordinatorT", bound=ShellyBlockCoordinator | ShellyRpcCoordinator
|
||||
)
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class ShellyButtonDescription(
|
||||
|
||||
|
||||
BUTTONS: Final[list[ShellyButtonDescription[Any]]] = [
|
||||
ShellyButtonDescription[Union[ShellyBlockCoordinator, ShellyRpcCoordinator]](
|
||||
ShellyButtonDescription[ShellyBlockCoordinator | ShellyRpcCoordinator](
|
||||
key="reboot",
|
||||
name="Reboot",
|
||||
device_class=ButtonDeviceClass.RESTART,
|
||||
@ -102,7 +102,7 @@ async def async_setup_entry(
|
||||
|
||||
|
||||
class ShellyButton(
|
||||
CoordinatorEntity[Union[ShellyRpcCoordinator, ShellyBlockCoordinator]], ButtonEntity
|
||||
CoordinatorEntity[ShellyRpcCoordinator | ShellyBlockCoordinator], ButtonEntity
|
||||
):
|
||||
"""Defines a Shelly base button."""
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""Define typing helpers for SimpliSafe."""
|
||||
from typing import Union
|
||||
|
||||
from simplipy.system.v2 import SystemV2
|
||||
from simplipy.system.v3 import SystemV3
|
||||
|
||||
SystemType = Union[SystemV2, SystemV3]
|
||||
SystemType = SystemV2 | SystemV3
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Entity for the SleepIQ integration."""
|
||||
from abc import abstractmethod
|
||||
from typing import TypeVar, Union
|
||||
from typing import TypeVar
|
||||
|
||||
from asyncsleepiq import SleepIQBed, SleepIQSleeper
|
||||
|
||||
@ -14,7 +14,7 @@ from .coordinator import SleepIQDataUpdateCoordinator, SleepIQPauseUpdateCoordin
|
||||
|
||||
_SleepIQCoordinatorT = TypeVar(
|
||||
"_SleepIQCoordinatorT",
|
||||
bound=Union[SleepIQDataUpdateCoordinator, SleepIQPauseUpdateCoordinator],
|
||||
bound=SleepIQDataUpdateCoordinator | SleepIQPauseUpdateCoordinator,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user