diff --git a/homeassistant/components/sonarr/coordinator.py b/homeassistant/components/sonarr/coordinator.py index 9b9a06b15f8..1010c196c21 100644 --- a/homeassistant/components/sonarr/coordinator.py +++ b/homeassistant/components/sonarr/coordinator.py @@ -2,7 +2,7 @@ from __future__ import annotations from datetime import timedelta -from typing import TypeVar, Union, cast +from typing import TypeVar, cast from aiopyarr import ( Command, @@ -27,15 +27,15 @@ from .const import CONF_UPCOMING_DAYS, CONF_WANTED_MAX_ITEMS, DOMAIN, LOGGER SonarrDataT = TypeVar( "SonarrDataT", - bound=Union[ - list[SonarrCalendar], - list[Command], - list[Diskspace], - SonarrQueue, - list[SonarrSeries], - SystemStatus, - SonarrWantedMissing, - ], + bound=( + list[SonarrCalendar] + | list[Command] + | list[Diskspace] + | SonarrQueue + | list[SonarrSeries] + | SystemStatus + | SonarrWantedMissing + ), ) diff --git a/homeassistant/components/steam_online/coordinator.py b/homeassistant/components/steam_online/coordinator.py index 30178fa2b82..719acecd1f2 100644 --- a/homeassistant/components/steam_online/coordinator.py +++ b/homeassistant/components/steam_online/coordinator.py @@ -2,7 +2,6 @@ from __future__ import annotations from datetime import timedelta -from typing import Union import steam from steam.api import _interface_method as INTMethod @@ -17,7 +16,7 @@ from .const import CONF_ACCOUNTS, DOMAIN, LOGGER class SteamDataUpdateCoordinator( - DataUpdateCoordinator[dict[str, dict[str, Union[str, int]]]] + DataUpdateCoordinator[dict[str, dict[str, str | int]]] ): """Data update coordinator for the Steam integration.""" diff --git a/homeassistant/components/switchbee/switch.py b/homeassistant/components/switchbee/switch.py index 9ed0e6ea9c0..f8f6e30e368 100644 --- a/homeassistant/components/switchbee/switch.py +++ b/homeassistant/components/switchbee/switch.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError from switchbee.device import ( @@ -25,12 +25,12 @@ from .entity import SwitchBeeDeviceEntity _DeviceTypeT = TypeVar( "_DeviceTypeT", - bound=Union[ - SwitchBeeTimedSwitch, - SwitchBeeGroupSwitch, - SwitchBeeSwitch, - SwitchBeeTimerSwitch, - ], + bound=( + SwitchBeeTimedSwitch + | SwitchBeeGroupSwitch + | SwitchBeeSwitch + | SwitchBeeTimerSwitch + ), ) diff --git a/homeassistant/components/unifi/entity.py b/homeassistant/components/unifi/entity.py index e7dca396fae..783950310e4 100644 --- a/homeassistant/components/unifi/entity.py +++ b/homeassistant/components/unifi/entity.py @@ -4,7 +4,7 @@ from __future__ import annotations from abc import abstractmethod from collections.abc import Callable from dataclasses import dataclass -from typing import TYPE_CHECKING, Generic, TypeVar, Union +from typing import TYPE_CHECKING, Generic, TypeVar import aiounifi from aiounifi.interfaces.api_handlers import ( @@ -31,8 +31,8 @@ from .const import ATTR_MANUFACTURER if TYPE_CHECKING: from .controller import UniFiController -DataT = TypeVar("DataT", bound=Union[APIItem, Outlet, Port]) -HandlerT = TypeVar("HandlerT", bound=Union[APIHandler, Outlets, Ports]) +DataT = TypeVar("DataT", bound=APIItem | Outlet | Port) +HandlerT = TypeVar("HandlerT", bound=APIHandler | Outlets | Ports) SubscriptionT = Callable[[CallbackType, ItemEvent], UnsubscribeType] diff --git a/homeassistant/components/unifiprotect/data.py b/homeassistant/components/unifiprotect/data.py index 5db0941549b..518eb623ca1 100644 --- a/homeassistant/components/unifiprotect/data.py +++ b/homeassistant/components/unifiprotect/data.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Callable, Generator, Iterable from datetime import timedelta import logging -from typing import Any, Union, cast +from typing import Any, cast from pyunifiprotect import ProtectApiClient from pyunifiprotect.data import ( @@ -39,7 +39,7 @@ from .const import ( from .utils import async_dispatch_id as _ufpd, async_get_devices_by_type _LOGGER = logging.getLogger(__name__) -ProtectDeviceType = Union[ProtectAdoptableDeviceModel, NVR] +ProtectDeviceType = ProtectAdoptableDeviceModel | NVR @callback diff --git a/homeassistant/components/unifiprotect/models.py b/homeassistant/components/unifiprotect/models.py index b7913567504..40280c02867 100644 --- a/homeassistant/components/unifiprotect/models.py +++ b/homeassistant/components/unifiprotect/models.py @@ -5,7 +5,7 @@ from collections.abc import Callable, Coroutine from dataclasses import dataclass from enum import Enum import logging -from typing import Any, Generic, TypeVar, Union, cast +from typing import Any, Generic, TypeVar, cast from pyunifiprotect.data import NVR, Event, ProtectAdoptableDeviceModel @@ -15,7 +15,7 @@ from .utils import get_nested_attr _LOGGER = logging.getLogger(__name__) -T = TypeVar("T", bound=Union[ProtectAdoptableDeviceModel, NVR]) +T = TypeVar("T", bound=ProtectAdoptableDeviceModel | NVR) class PermRequired(int, Enum): diff --git a/homeassistant/components/withings/common.py b/homeassistant/components/withings/common.py index c1616a062ca..9b12c825a20 100644 --- a/homeassistant/components/withings/common.py +++ b/homeassistant/components/withings/common.py @@ -10,7 +10,7 @@ from enum import IntEnum from http import HTTPStatus import logging import re -from typing import Any, Union +from typing import Any from aiohttp.web import Response import requests @@ -241,7 +241,7 @@ class DataManager: update_method=self.async_subscribe_webhook, ) self.poll_data_update_coordinator = DataUpdateCoordinator[ - Union[dict[MeasureType, Any], None] + dict[MeasureType, Any] | None ]( hass, _LOGGER, diff --git a/homeassistant/components/zwave_js/discovery_data_template.py b/homeassistant/components/zwave_js/discovery_data_template.py index 7d9f20b111e..82d2b9ffc44 100644 --- a/homeassistant/components/zwave_js/discovery_data_template.py +++ b/homeassistant/components/zwave_js/discovery_data_template.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Iterable, Mapping from dataclasses import dataclass, field import logging -from typing import Any, Union, cast +from typing import Any, cast from zwave_js_server.const import CommandClass from zwave_js_server.const.command_class.meter import ( @@ -497,7 +497,7 @@ class ConfigurableFanValueMappingDataTemplate( ) -> dict[str, ZwaveConfigurationValue | None]: """Resolve helper class data for a discovered value.""" zwave_value = cast( - Union[ZwaveConfigurationValue, None], + ZwaveConfigurationValue | None, self._get_value_from_id(value.node, self.configuration_option), ) return {"configuration_value": zwave_value}