Remove zha from mypy ignore list (#73603)
parent
4b5c0be896
commit
8bed2e6459
|
@ -221,7 +221,7 @@ class ChannelPool:
|
|||
return self._channels.zha_device.is_mains_powered
|
||||
|
||||
@property
|
||||
def manufacturer(self) -> str | None:
|
||||
def manufacturer(self) -> str:
|
||||
"""Return device manufacturer."""
|
||||
return self._channels.zha_device.manufacturer
|
||||
|
||||
|
@ -236,7 +236,7 @@ class ChannelPool:
|
|||
return self._channels.zha_device.hass
|
||||
|
||||
@property
|
||||
def model(self) -> str | None:
|
||||
def model(self) -> str:
|
||||
"""Return device model."""
|
||||
return self._channels.zha_device.model
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from collections.abc import Callable
|
|||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant import const as ha_const
|
||||
from homeassistant.const import CONF_TYPE, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
|
@ -86,9 +86,7 @@ class ProbeEndpoint:
|
|||
|
||||
unique_id = channel_pool.unique_id
|
||||
|
||||
component: str | None = self._device_configs.get(unique_id, {}).get(
|
||||
ha_const.CONF_TYPE
|
||||
)
|
||||
component: str | None = self._device_configs.get(unique_id, {}).get(CONF_TYPE)
|
||||
if component is None:
|
||||
ep_profile_id = channel_pool.endpoint.profile_id
|
||||
ep_device_type = channel_pool.endpoint.device_type
|
||||
|
@ -136,7 +134,7 @@ class ProbeEndpoint:
|
|||
|
||||
@staticmethod
|
||||
def probe_single_cluster(
|
||||
component: str,
|
||||
component: Platform | None,
|
||||
channel: base.ZigbeeChannel,
|
||||
ep_channels: ChannelPool,
|
||||
) -> None:
|
||||
|
|
|
@ -110,7 +110,7 @@ CLIENT_CHANNELS_REGISTRY: DictRegistry[type[ClientChannel]] = DictRegistry()
|
|||
ZIGBEE_CHANNEL_REGISTRY: DictRegistry[type[ZigbeeChannel]] = DictRegistry()
|
||||
|
||||
|
||||
def set_or_callable(value):
|
||||
def set_or_callable(value) -> frozenset[str] | Callable:
|
||||
"""Convert single str or None to a set. Pass through callables and sets."""
|
||||
if value is None:
|
||||
return frozenset()
|
||||
|
@ -121,22 +121,26 @@ def set_or_callable(value):
|
|||
return frozenset([str(value)])
|
||||
|
||||
|
||||
def _get_empty_frozenset() -> frozenset[str]:
|
||||
return frozenset()
|
||||
|
||||
|
||||
@attr.s(frozen=True)
|
||||
class MatchRule:
|
||||
"""Match a ZHA Entity to a channel name or generic id."""
|
||||
|
||||
channel_names: set[str] | str = attr.ib(
|
||||
channel_names: frozenset[str] = attr.ib(
|
||||
factory=frozenset, converter=set_or_callable
|
||||
)
|
||||
generic_ids: set[str] | str = attr.ib(factory=frozenset, converter=set_or_callable)
|
||||
manufacturers: Callable | set[str] | str = attr.ib(
|
||||
factory=frozenset, converter=set_or_callable
|
||||
generic_ids: frozenset[str] = attr.ib(factory=frozenset, converter=set_or_callable)
|
||||
manufacturers: frozenset[str] | Callable = attr.ib(
|
||||
factory=_get_empty_frozenset, converter=set_or_callable
|
||||
)
|
||||
models: Callable | set[str] | str = attr.ib(
|
||||
factory=frozenset, converter=set_or_callable
|
||||
models: frozenset[str] | Callable = attr.ib(
|
||||
factory=_get_empty_frozenset, converter=set_or_callable
|
||||
)
|
||||
aux_channels: Callable | set[str] | str = attr.ib(
|
||||
factory=frozenset, converter=set_or_callable
|
||||
aux_channels: frozenset[str] | Callable = attr.ib(
|
||||
factory=_get_empty_frozenset, converter=set_or_callable
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -162,7 +166,8 @@ class MatchRule:
|
|||
|
||||
weight += 10 * len(self.channel_names)
|
||||
weight += 5 * len(self.generic_ids)
|
||||
weight += 1 * len(self.aux_channels)
|
||||
if isinstance(self.aux_channels, frozenset):
|
||||
weight += 1 * len(self.aux_channels)
|
||||
return weight
|
||||
|
||||
def claim_channels(self, channel_pool: list[ZigbeeChannel]) -> list[ZigbeeChannel]:
|
||||
|
@ -321,11 +326,11 @@ class ZHAEntityRegistry:
|
|||
def strict_match(
|
||||
self,
|
||||
component: str,
|
||||
channel_names: set[str] | str = None,
|
||||
generic_ids: set[str] | str = None,
|
||||
manufacturers: Callable | set[str] | str = None,
|
||||
models: Callable | set[str] | str = None,
|
||||
aux_channels: Callable | set[str] | str = None,
|
||||
channel_names: set[str] | str | None = None,
|
||||
generic_ids: set[str] | str | None = None,
|
||||
manufacturers: Callable | set[str] | str | None = None,
|
||||
models: Callable | set[str] | str | None = None,
|
||||
aux_channels: Callable | set[str] | str | None = None,
|
||||
) -> Callable[[_ZhaEntityT], _ZhaEntityT]:
|
||||
"""Decorate a strict match rule."""
|
||||
|
||||
|
@ -346,11 +351,11 @@ class ZHAEntityRegistry:
|
|||
def multipass_match(
|
||||
self,
|
||||
component: str,
|
||||
channel_names: set[str] | str = None,
|
||||
generic_ids: set[str] | str = None,
|
||||
manufacturers: Callable | set[str] | str = None,
|
||||
models: Callable | set[str] | str = None,
|
||||
aux_channels: Callable | set[str] | str = None,
|
||||
channel_names: set[str] | str | None = None,
|
||||
generic_ids: set[str] | str | None = None,
|
||||
manufacturers: Callable | set[str] | str | None = None,
|
||||
models: Callable | set[str] | str | None = None,
|
||||
aux_channels: Callable | set[str] | str | None = None,
|
||||
stop_on_match_group: int | str | None = None,
|
||||
) -> Callable[[_ZhaEntityT], _ZhaEntityT]:
|
||||
"""Decorate a loose match rule."""
|
||||
|
@ -379,11 +384,11 @@ class ZHAEntityRegistry:
|
|||
def config_diagnostic_match(
|
||||
self,
|
||||
component: str,
|
||||
channel_names: set[str] | str = None,
|
||||
generic_ids: set[str] | str = None,
|
||||
manufacturers: Callable | set[str] | str = None,
|
||||
models: Callable | set[str] | str = None,
|
||||
aux_channels: Callable | set[str] | str = None,
|
||||
channel_names: set[str] | str | None = None,
|
||||
generic_ids: set[str] | str | None = None,
|
||||
manufacturers: Callable | set[str] | str | None = None,
|
||||
models: Callable | set[str] | str | None = None,
|
||||
aux_channels: Callable | set[str] | str | None = None,
|
||||
stop_on_match_group: int | str | None = None,
|
||||
) -> Callable[[_ZhaEntityT], _ZhaEntityT]:
|
||||
"""Decorate a loose match rule."""
|
||||
|
@ -432,9 +437,9 @@ class ZHAEntityRegistry:
|
|||
|
||||
def clean_up(self) -> None:
|
||||
"""Clean up post discovery."""
|
||||
self.single_device_matches: dict[
|
||||
Platform, dict[EUI64, list[str]]
|
||||
] = collections.defaultdict(lambda: collections.defaultdict(list))
|
||||
self.single_device_matches = collections.defaultdict(
|
||||
lambda: collections.defaultdict(list)
|
||||
)
|
||||
|
||||
|
||||
ZHA_ENTITIES = ZHAEntityRegistry()
|
||||
|
|
6
mypy.ini
6
mypy.ini
|
@ -2995,9 +2995,3 @@ ignore_errors = true
|
|||
|
||||
[mypy-homeassistant.components.xiaomi_miio.switch]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.discovery]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.zha.core.registries]
|
||||
ignore_errors = true
|
||||
|
|
|
@ -144,8 +144,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||
"homeassistant.components.xiaomi_miio.light",
|
||||
"homeassistant.components.xiaomi_miio.sensor",
|
||||
"homeassistant.components.xiaomi_miio.switch",
|
||||
"homeassistant.components.zha.core.discovery",
|
||||
"homeassistant.components.zha.core.registries",
|
||||
]
|
||||
|
||||
# Component modules which should set no_implicit_reexport = true.
|
||||
|
|
Loading…
Reference in New Issue