Update Union typing (3) [Py310] (#86426)

This commit is contained in:
Marc Mueller 2023-01-23 10:05:56 +01:00 committed by GitHub
parent 4f87c1f30f
commit ab76b3ffb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 30 deletions

View file

@ -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
),
)

View file

@ -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."""

View file

@ -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
),
)

View file

@ -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]

View file

@ -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

View file

@ -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):

View file

@ -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,

View file

@ -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}