Update Union typing (zha) [Py310] (#86453)

This commit is contained in:
Marc Mueller 2023-01-23 14:46:40 +01:00 committed by GitHub
parent 6582ee3591
commit 00e5f23249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -2,12 +2,12 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Callable from collections.abc import Callable
from typing import Any, TypeVar, Union from typing import Any, TypeVar
_TypeT = TypeVar("_TypeT", bound=type[Any]) _TypeT = TypeVar("_TypeT", bound=type[Any])
class DictRegistry(dict[Union[int, str], _TypeT]): class DictRegistry(dict[int | str, _TypeT]):
"""Dict Registry of items.""" """Dict Registry of items."""
def register(self, name: int | str) -> Callable[[_TypeT], _TypeT]: def register(self, name: int | str) -> Callable[[_TypeT], _TypeT]:
@ -21,7 +21,7 @@ class DictRegistry(dict[Union[int, str], _TypeT]):
return decorator return decorator
class SetRegistry(set[Union[int, str]]): class SetRegistry(set[int | str]):
"""Set Registry of items.""" """Set Registry of items."""
def register(self, name: int | str) -> Callable[[_TypeT], _TypeT]: def register(self, name: int | str) -> Callable[[_TypeT], _TypeT]:

View File

@ -11,7 +11,7 @@ import logging
import re import re
import time import time
import traceback import traceback
from typing import TYPE_CHECKING, Any, NamedTuple, Union from typing import TYPE_CHECKING, Any, NamedTuple
from zigpy.application import ControllerApplication from zigpy.application import ControllerApplication
from zigpy.config import CONF_DEVICE from zigpy.config import CONF_DEVICE
@ -91,7 +91,7 @@ if TYPE_CHECKING:
from ..entity import ZhaEntity from ..entity import ZhaEntity
from .channels.base import ZigbeeChannel from .channels.base import ZigbeeChannel
_LogFilterType = Union[Filter, Callable[[LogRecord], int]] _LogFilterType = Filter | Callable[[LogRecord], int]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -1,5 +1,6 @@
"""Test ZHA device switch.""" """Test ZHA device switch."""
from datetime import timedelta from datetime import timedelta
import logging
import time import time
from unittest import mock from unittest import mock
from unittest.mock import patch from unittest.mock import patch
@ -224,6 +225,7 @@ async def test_check_available_no_basic_channel(
hass, device_without_basic_channel, zha_device_restored, caplog hass, device_without_basic_channel, zha_device_restored, caplog
): ):
"""Check device availability for a device without basic cluster.""" """Check device availability for a device without basic cluster."""
caplog.set_level(logging.DEBUG, logger="homeassistant.components.zha")
zha_device = await zha_device_restored(device_without_basic_channel) zha_device = await zha_device_restored(device_without_basic_channel)
await async_enable_traffic(hass, [zha_device]) await async_enable_traffic(hass, [zha_device])