Update Union typing (3) [Py310] (#86426)
This commit is contained in:
parent
4f87c1f30f
commit
ab76b3ffb3
8 changed files with 29 additions and 30 deletions
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import TypeVar, Union, cast
|
from typing import TypeVar, cast
|
||||||
|
|
||||||
from aiopyarr import (
|
from aiopyarr import (
|
||||||
Command,
|
Command,
|
||||||
|
@ -27,15 +27,15 @@ from .const import CONF_UPCOMING_DAYS, CONF_WANTED_MAX_ITEMS, DOMAIN, LOGGER
|
||||||
|
|
||||||
SonarrDataT = TypeVar(
|
SonarrDataT = TypeVar(
|
||||||
"SonarrDataT",
|
"SonarrDataT",
|
||||||
bound=Union[
|
bound=(
|
||||||
list[SonarrCalendar],
|
list[SonarrCalendar]
|
||||||
list[Command],
|
| list[Command]
|
||||||
list[Diskspace],
|
| list[Diskspace]
|
||||||
SonarrQueue,
|
| SonarrQueue
|
||||||
list[SonarrSeries],
|
| list[SonarrSeries]
|
||||||
SystemStatus,
|
| SystemStatus
|
||||||
SonarrWantedMissing,
|
| SonarrWantedMissing
|
||||||
],
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
import steam
|
import steam
|
||||||
from steam.api import _interface_method as INTMethod
|
from steam.api import _interface_method as INTMethod
|
||||||
|
@ -17,7 +16,7 @@ from .const import CONF_ACCOUNTS, DOMAIN, LOGGER
|
||||||
|
|
||||||
|
|
||||||
class SteamDataUpdateCoordinator(
|
class SteamDataUpdateCoordinator(
|
||||||
DataUpdateCoordinator[dict[str, dict[str, Union[str, int]]]]
|
DataUpdateCoordinator[dict[str, dict[str, str | int]]]
|
||||||
):
|
):
|
||||||
"""Data update coordinator for the Steam integration."""
|
"""Data update coordinator for the Steam integration."""
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
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.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
|
||||||
from switchbee.device import (
|
from switchbee.device import (
|
||||||
|
@ -25,12 +25,12 @@ from .entity import SwitchBeeDeviceEntity
|
||||||
|
|
||||||
_DeviceTypeT = TypeVar(
|
_DeviceTypeT = TypeVar(
|
||||||
"_DeviceTypeT",
|
"_DeviceTypeT",
|
||||||
bound=Union[
|
bound=(
|
||||||
SwitchBeeTimedSwitch,
|
SwitchBeeTimedSwitch
|
||||||
SwitchBeeGroupSwitch,
|
| SwitchBeeGroupSwitch
|
||||||
SwitchBeeSwitch,
|
| SwitchBeeSwitch
|
||||||
SwitchBeeTimerSwitch,
|
| SwitchBeeTimerSwitch
|
||||||
],
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import TYPE_CHECKING, Generic, TypeVar, Union
|
from typing import TYPE_CHECKING, Generic, TypeVar
|
||||||
|
|
||||||
import aiounifi
|
import aiounifi
|
||||||
from aiounifi.interfaces.api_handlers import (
|
from aiounifi.interfaces.api_handlers import (
|
||||||
|
@ -31,8 +31,8 @@ from .const import ATTR_MANUFACTURER
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .controller import UniFiController
|
from .controller import UniFiController
|
||||||
|
|
||||||
DataT = TypeVar("DataT", bound=Union[APIItem, Outlet, Port])
|
DataT = TypeVar("DataT", bound=APIItem | Outlet | Port)
|
||||||
HandlerT = TypeVar("HandlerT", bound=Union[APIHandler, Outlets, Ports])
|
HandlerT = TypeVar("HandlerT", bound=APIHandler | Outlets | Ports)
|
||||||
SubscriptionT = Callable[[CallbackType, ItemEvent], UnsubscribeType]
|
SubscriptionT = Callable[[CallbackType, ItemEvent], UnsubscribeType]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from collections.abc import Callable, Generator, Iterable
|
from collections.abc import Callable, Generator, Iterable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Union, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from pyunifiprotect import ProtectApiClient
|
from pyunifiprotect import ProtectApiClient
|
||||||
from pyunifiprotect.data import (
|
from pyunifiprotect.data import (
|
||||||
|
@ -39,7 +39,7 @@ from .const import (
|
||||||
from .utils import async_dispatch_id as _ufpd, async_get_devices_by_type
|
from .utils import async_dispatch_id as _ufpd, async_get_devices_by_type
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
ProtectDeviceType = Union[ProtectAdoptableDeviceModel, NVR]
|
ProtectDeviceType = ProtectAdoptableDeviceModel | NVR
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -5,7 +5,7 @@ from collections.abc import Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Generic, TypeVar, Union, cast
|
from typing import Any, Generic, TypeVar, cast
|
||||||
|
|
||||||
from pyunifiprotect.data import NVR, Event, ProtectAdoptableDeviceModel
|
from pyunifiprotect.data import NVR, Event, ProtectAdoptableDeviceModel
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from .utils import get_nested_attr
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
T = TypeVar("T", bound=Union[ProtectAdoptableDeviceModel, NVR])
|
T = TypeVar("T", bound=ProtectAdoptableDeviceModel | NVR)
|
||||||
|
|
||||||
|
|
||||||
class PermRequired(int, Enum):
|
class PermRequired(int, Enum):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from enum import IntEnum
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Any, Union
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.web import Response
|
from aiohttp.web import Response
|
||||||
import requests
|
import requests
|
||||||
|
@ -241,7 +241,7 @@ class DataManager:
|
||||||
update_method=self.async_subscribe_webhook,
|
update_method=self.async_subscribe_webhook,
|
||||||
)
|
)
|
||||||
self.poll_data_update_coordinator = DataUpdateCoordinator[
|
self.poll_data_update_coordinator = DataUpdateCoordinator[
|
||||||
Union[dict[MeasureType, Any], None]
|
dict[MeasureType, Any] | None
|
||||||
](
|
](
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from collections.abc import Iterable, Mapping
|
from collections.abc import Iterable, Mapping
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
import logging
|
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 import CommandClass
|
||||||
from zwave_js_server.const.command_class.meter import (
|
from zwave_js_server.const.command_class.meter import (
|
||||||
|
@ -497,7 +497,7 @@ class ConfigurableFanValueMappingDataTemplate(
|
||||||
) -> dict[str, ZwaveConfigurationValue | None]:
|
) -> dict[str, ZwaveConfigurationValue | None]:
|
||||||
"""Resolve helper class data for a discovered value."""
|
"""Resolve helper class data for a discovered value."""
|
||||||
zwave_value = cast(
|
zwave_value = cast(
|
||||||
Union[ZwaveConfigurationValue, None],
|
ZwaveConfigurationValue | None,
|
||||||
self._get_value_from_id(value.node, self.configuration_option),
|
self._get_value_from_id(value.node, self.configuration_option),
|
||||||
)
|
)
|
||||||
return {"configuration_value": zwave_value}
|
return {"configuration_value": zwave_value}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue