Remove unnecessary type definitions in zha (#73735)

* Cleanup ZigpyClusterType

* Cleanup ZigpyDeviceType

* Cleanup ZigpyEndpointType

* Cleanup ZigpyGroupType

* Cleanup ZigpyZdoType
pull/73744/head
epenet 2022-06-20 12:49:40 +02:00 committed by GitHub
parent b145aeaf75
commit 2de4b193e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 37 deletions

View File

@ -8,6 +8,7 @@ import logging
from typing import TYPE_CHECKING, Any
import zigpy.exceptions
import zigpy.zcl
from zigpy.zcl.foundation import (
CommandSchema,
ConfigureReportingResponseRecord,
@ -19,7 +20,6 @@ from homeassistant.const import ATTR_COMMAND
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from .. import typing as zha_typing
from ..const import (
ATTR_ARGS,
ATTR_ATTRIBUTE_ID,
@ -107,9 +107,7 @@ class ZigbeeChannel(LogMixin):
# attribute read is acceptable.
ZCL_INIT_ATTRS: dict[int | str, bool] = {}
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
) -> None:
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
"""Initialize ZigbeeChannel."""
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
self._ch_pool = ch_pool

View File

@ -7,13 +7,14 @@ from typing import TYPE_CHECKING, Any
import zigpy.exceptions
import zigpy.types as t
import zigpy.zcl
from zigpy.zcl.clusters import general
from zigpy.zcl.foundation import Status
from homeassistant.core import callback
from homeassistant.helpers.event import async_call_later
from .. import registries, typing as zha_typing
from .. import registries
from ..const import (
REPORT_CONFIG_ASAP,
REPORT_CONFIG_BATTERY_SAVE,
@ -307,9 +308,7 @@ class OnOffChannel(ZigbeeChannel):
"start_up_on_off": True,
}
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
) -> None:
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
"""Initialize OnOffChannel."""
super().__init__(cluster, ch_pool)
self._off_listener = None

View File

@ -4,9 +4,11 @@ from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import zigpy.zcl
from homeassistant.core import callback
from .. import registries, typing as zha_typing
from .. import registries
from ..const import (
ATTR_ATTRIBUTE_ID,
ATTR_ATTRIBUTE_NAME,
@ -60,9 +62,7 @@ class OppleRemote(ZigbeeChannel):
REPORT_CONFIG = []
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
) -> None:
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
"""Initialize Opple channel."""
super().__init__(cluster, ch_pool)
if self.cluster.endpoint.model == "lumi.motion.ac02":

View File

@ -10,12 +10,13 @@ import asyncio
from typing import TYPE_CHECKING
from zigpy.exceptions import ZigbeeException
import zigpy.zcl
from zigpy.zcl.clusters import security
from zigpy.zcl.clusters.security import IasAce as AceCluster
from homeassistant.core import callback
from .. import registries, typing as zha_typing
from .. import registries
from ..const import (
SIGNAL_ATTR_UPDATED,
WARNING_DEVICE_MODE_EMERGENCY,
@ -51,9 +52,7 @@ SIGNAL_ALARM_TRIGGERED = "zha_armed_triggered"
class IasAce(ZigbeeChannel):
"""IAS Ancillary Control Equipment channel."""
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
) -> None:
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
"""Initialize IAS Ancillary Control Equipment channel."""
super().__init__(cluster, ch_pool)
self.command_map: dict[int, CALLABLE_T] = {

View File

@ -5,9 +5,10 @@ import enum
from functools import partialmethod
from typing import TYPE_CHECKING
import zigpy.zcl
from zigpy.zcl.clusters import smartenergy
from .. import registries, typing as zha_typing
from .. import registries
from ..const import (
REPORT_CONFIG_ASAP,
REPORT_CONFIG_DEFAULT,
@ -118,9 +119,7 @@ class Metering(ZigbeeChannel):
DEMAND = 0
SUMMATION = 1
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: ChannelPool
) -> None:
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
"""Initialize Metering."""
super().__init__(cluster, ch_pool)
self._format_spec = None

View File

@ -12,6 +12,7 @@ import time
from typing import TYPE_CHECKING, Any
from zigpy import types
import zigpy.device
import zigpy.exceptions
from zigpy.profiles import PROFILES
import zigpy.quirks
@ -27,7 +28,7 @@ from homeassistant.helpers.dispatcher import (
)
from homeassistant.helpers.event import async_track_time_interval
from . import channels, typing as zha_typing
from . import channels
from .const import (
ATTR_ARGS,
ATTR_ATTRIBUTE,
@ -100,7 +101,7 @@ class ZHADevice(LogMixin):
def __init__(
self,
hass: HomeAssistant,
zigpy_device: zha_typing.ZigpyDeviceType,
zigpy_device: zigpy.device.Device,
zha_gateway: ZHAGateway,
) -> None:
"""Initialize the gateway."""
@ -151,7 +152,7 @@ class ZHADevice(LogMixin):
self._ha_device_id = device_id
@property
def device(self) -> zha_typing.ZigpyDeviceType:
def device(self) -> zigpy.device.Device:
"""Return underlying Zigpy device."""
return self._zigpy_device
@ -332,7 +333,7 @@ class ZHADevice(LogMixin):
def new(
cls,
hass: HomeAssistant,
zigpy_dev: zha_typing.ZigpyDeviceType,
zigpy_dev: zigpy.device.Device,
gateway: ZHAGateway,
restored: bool = False,
):

View File

@ -21,6 +21,7 @@ import voluptuous as vol
import zigpy.exceptions
import zigpy.types
import zigpy.util
import zigpy.zcl
import zigpy.zdo.types as zdo_types
from homeassistant.config_entries import ConfigEntry
@ -35,7 +36,6 @@ from .const import (
DATA_ZHA_GATEWAY,
)
from .registries import BINDABLE_CLUSTERS
from .typing import ZigpyClusterType
if TYPE_CHECKING:
from .device import ZHADevice
@ -48,7 +48,7 @@ _T = TypeVar("_T")
class BindingPair:
"""Information for binding."""
source_cluster: ZigpyClusterType
source_cluster: zigpy.zcl.Cluster
target_ieee: zigpy.types.EUI64
target_ep_id: int

View File

@ -2,16 +2,5 @@
from collections.abc import Callable
from typing import TypeVar
import zigpy.device
import zigpy.endpoint
import zigpy.group
import zigpy.zcl
import zigpy.zdo
# pylint: disable=invalid-name
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable)
ZigpyClusterType = zigpy.zcl.Cluster
ZigpyDeviceType = zigpy.device.Device
ZigpyEndpointType = zigpy.endpoint.Endpoint
ZigpyGroupType = zigpy.group.Group
ZigpyZdoType = zigpy.zdo.ZDO