Skip to content

Commit 4e43ad9

Browse files
Copilotpuddly
andcommitted
Fix mypy type errors for zigpy 0.91.2 compatibility
Co-authored-by: puddly <32534428+puddly@users.noreply.github.com>
1 parent b161639 commit 4e43ad9

File tree

12 files changed

+33
-21
lines changed

12 files changed

+33
-21
lines changed

tests/application/test_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ async def test_send_security_and_packet_source_route(device, make_application, m
773773
tx_options=(
774774
zigpy_t.TransmitOptions.ACK | zigpy_t.TransmitOptions.APS_Encryption
775775
),
776-
source_route=[0xAABB, 0xCCDD],
776+
source_route=[zigpy_t.NWK(0xAABB), zigpy_t.NWK(0xCCDD)],
777777
)
778778

779779
data_req = znp_server.reply_once_to(

tests/application/test_startup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"CC2652",
2626
f"Z-Stack {FormedLaunchpadCC26X2R1.code_revision}",
2727
15,
28-
t.Channels.from_channel_list([15]),
28+
t.Channels.from_channel_list([15]), # type: ignore[misc]
2929
0x4402,
3030
t.EUI64.convert("A2:BA:38:A8:B5:E6:83:A0"),
3131
t.KeyData.convert("4C:4E:72:B8:41:22:51:79:9A:BF:35:25:12:88:CA:83"),
@@ -34,7 +34,7 @@
3434
"CC2531",
3535
f"Z-Stack 3.0.x {FormedZStack3CC2531.code_revision}",
3636
15,
37-
t.Channels.from_channel_list([15]),
37+
t.Channels.from_channel_list([15]), # type: ignore[misc]
3838
0xB6AB,
3939
t.EUI64.convert("62:92:32:46:3C:77:2D:B2"),
4040
t.KeyData.convert("6D:DE:24:EA:E2:85:52:B6:DE:29:56:EB:05:85:1A:FA"),
@@ -43,7 +43,7 @@
4343
"CC2531",
4444
f"Z-Stack Home 1.2 {FormedZStack1CC2531.code_revision}",
4545
11,
46-
t.Channels.from_channel_list([11]),
46+
t.Channels.from_channel_list([11]), # type: ignore[misc]
4747
0x1A62,
4848
t.EUI64.convert("DD:DD:DD:DD:DD:DD:DD:DD"),
4949
t.KeyData([1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13]),

tests/application/test_zdo_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async def update_channel(req):
5656
request=c.ZDO.MgmtNWKUpdateReq.Req(
5757
Dst=0x0000,
5858
DstAddrMode=t.AddrMode.NWK,
59-
Channels=t.Channels.from_channel_list([new_channel]),
59+
Channels=t.Channels.from_channel_list([new_channel]), # type: ignore[misc]
6060
ScanDuration=254,
6161
# Missing fields in the request cannot be `None` in the Z-Stack command
6262
ScanCount=0,

tests/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def test_command_optional_params_failures():
335335

336336

337337
def test_simple_descriptor():
338-
lvlist16_type = zigpy_t.LVList[t.uint16_t]
338+
lvlist16_type = zigpy_t.LVList[zigpy_t.uint8_t, t.uint16_t]
339339

340340
simple_descriptor = zigpy.zdo.types.SimpleDescriptor()
341341
simple_descriptor.endpoint = zigpy_t.uint8_t(1)

tests/tools/test_network_backup_restore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async def test_network_backup_formed(device, make_znp_server, tmp_path):
182182
assert backup["nwk_update_id"] == 0
183183
assert backup["security_level"] == 5
184184
assert backup["channel"] == channel
185-
assert t.Channels.from_channel_list(backup["channel_mask"]) == channels
185+
assert t.Channels.from_channel_list(backup["channel_mask"]) == channels # type: ignore[misc]
186186

187187
assert t.KeyData(bytes.fromhex(backup["network_key"]["key"])) == network_key
188188
assert backup["network_key"]["sequence_number"] == 0

zigpy_znp/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
)
2626

2727
# Used only when creating a temporary network during formation
28-
STARTUP_CHANNELS = t.Channels.from_channel_list([15, 20, 25])
28+
STARTUP_CHANNELS = t.Channels.from_channel_list([15, 20, 25]) # type: ignore[misc]

zigpy_znp/tools/network_restore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def json_backup_to_zigpy_state(
3636
network_info.nwk_update_id = backup["nwk_update_id"]
3737
network_info.nwk_manager_id = 0x0000
3838
network_info.channel = backup["channel"]
39-
network_info.channel_mask = t.Channels.from_channel_list(backup["channel_mask"])
39+
network_info.channel_mask = t.Channels.from_channel_list(backup["channel_mask"]) # type: ignore[misc]
4040
network_info.security_level = backup["security_level"]
4141
network_info.stack_specific = backup.get("stack_specific")
4242
network_info.tc_link_key = zigpy.state.Key()

zigpy_znp/tools/network_scan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def main(argv):
106106
"-c",
107107
"--channels",
108108
dest="channels",
109-
type=lambda s: t.Channels.from_channel_list(map(int, s.split(","))),
109+
type=lambda s: t.Channels.from_channel_list(map(int, s.split(","))), # type: ignore[misc]
110110
default=t.Channels.ALL_CHANNELS,
111111
help="Channels on which to scan for networks",
112112
)

zigpy_znp/uart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def close(self) -> None:
3131
super().close()
3232
self._api = None
3333

34-
def connection_lost(self, exc: Exception | None) -> None:
34+
def connection_lost(self, exc: BaseException | None) -> None:
3535
"""Connection lost."""
3636
super().connection_lost(exc)
3737

@@ -155,4 +155,4 @@ async def connect(config: conf.ConfigType, api) -> ZnpMtProtocol:
155155

156156
await protocol.wait_until_connected()
157157

158-
return protocol
158+
return protocol # type: ignore[return-value]

zigpy_znp/zigbee/application.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ async def start_network(self, *, read_only=False):
173173
self.devices[self.state.node_info.ieee] = ZNPCoordinator(
174174
self, self.state.node_info.ieee, self.state.node_info.nwk
175175
)
176-
await self._device.schedule_initialize()
176+
task = self._device.schedule_initialize()
177+
if task is not None:
178+
await task
177179

178180
# Deprecate ZNP-specific config
179181
if self.znp_config[conf.CONF_MAX_CONCURRENT_REQUESTS] is not None:
@@ -199,7 +201,7 @@ async def start_network(self, *, read_only=False):
199201
"Your network is using the insecure Zigbee2MQTT network key!"
200202
)
201203

202-
async def set_tx_power(self, dbm: int) -> None:
204+
async def set_tx_power(self, dbm: float) -> None:
203205
"""
204206
Sets the radio TX power.
205207
"""
@@ -237,7 +239,7 @@ def get_dst_address(self, cluster: zigpy.zcl.Cluster) -> zdo_t.MultiAddress:
237239

238240
return dst_addr
239241

240-
async def permit(self, time_s: int = 60, node: t.EUI64 = None):
242+
async def permit(self, time_s: int = 60, node: t.EUI64 | str | None = None):
241243
"""
242244
Permit joining the network via a specific node or via all router nodes.
243245
"""
@@ -273,7 +275,7 @@ async def permit(self, time_s: int = 60, node: t.EUI64 = None):
273275

274276
await super().permit(time_s=time_s, node=node)
275277

276-
async def permit_ncp(self, time_s: int) -> None:
278+
async def permit_ncp(self, time_s: int = 60) -> None:
277279
"""
278280
Permits joins only on the coordinator.
279281
"""
@@ -334,7 +336,7 @@ async def _move_network_to_channel(
334336
request=c.ZDO.MgmtNWKUpdateReq.Req(
335337
Dst=0x0000,
336338
DstAddrMode=t.AddrMode.NWK,
337-
Channels=t.Channels.from_channel_list([new_channel]),
339+
Channels=t.Channels.from_channel_list([new_channel]), # type: ignore[misc]
338340
ScanDuration=zdo_t.NwkUpdate.CHANNEL_CHANGE_REQ,
339341
ScanCount=0,
340342
NwkManagerAddr=0x0000,

0 commit comments

Comments
 (0)