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