Skip to content

Commit 55bdc1c

Browse files
authored
Drop Python 3.9 and 3.10 compatibility (#692)
* Drop Python 3.9 and 3.10 compat * pre-commit * Ensure app unit tests are async
1 parent 07a2e42 commit 55bdc1c

File tree

22 files changed

+52
-96
lines changed

22 files changed

+52
-96
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
with:
1111
CODE_FOLDER: bellows
1212
CACHE_VERSION: 2
13-
PYTHON_VERSION_DEFAULT: 3.9.15
13+
PYTHON_VERSION_DEFAULT: 3.11.0
1414
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit
1515
MINIMUM_COVERAGE_PERCENTAGE: 99
1616
secrets:

bellows/ash.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import abc
44
import asyncio
5+
from asyncio import timeout as asyncio_timeout
56
import binascii
67
from collections.abc import Coroutine
78
import contextlib
@@ -12,11 +13,6 @@
1213
import time
1314
import typing
1415

15-
if sys.version_info[:2] < (3, 11):
16-
from async_timeout import timeout as asyncio_timeout # pragma: no cover
17-
else:
18-
from asyncio import timeout as asyncio_timeout # pragma: no cover
19-
2016
from zigpy.types import BaseDataclassMixin
2117

2218
import bellows.types as t
@@ -675,7 +671,7 @@ async def _send_data_frame(self, frame: AshFrame) -> None:
675671
"NCP has entered into a failed state, not retrying"
676672
)
677673
raise
678-
except asyncio.TimeoutError:
674+
except TimeoutError:
679675
_LOGGER.debug(
680676
"No ACK received in %0.2fs (attempt %d) for %r",
681677
self._t_rx_ack,

bellows/ezsp/__init__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
from __future__ import annotations
44

55
import asyncio
6+
from asyncio import timeout as asyncio_timeout
67
import collections
8+
from collections.abc import Callable, Generator
79
import contextlib
810
import dataclasses
911
import functools
1012
import logging
11-
import sys
12-
from typing import Any, Callable, Generator
13+
from typing import Any
1314
import urllib.parse
1415

15-
from bellows.ash import NcpFailure
16-
17-
if sys.version_info[:2] < (3, 11):
18-
from async_timeout import timeout as asyncio_timeout # pragma: no cover
19-
else:
20-
from asyncio import timeout as asyncio_timeout # pragma: no cover
21-
2216
import zigpy.config
2317

18+
from bellows.ash import NcpFailure
2419
import bellows.config as conf
2520
from bellows.exception import EzspError, InvalidCommandError, InvalidCommandPayload
2621
from bellows.ezsp import xncp
@@ -119,7 +114,7 @@ async def startup_reset(self) -> None:
119114
try:
120115
async with asyncio_timeout(NETWORK_COORDINATOR_STARTUP_RESET_WAIT):
121116
await self._gw.wait_for_startup_reset()
122-
except asyncio.TimeoutError:
117+
except TimeoutError:
123118
pass
124119
else:
125120
LOGGER.debug("Received a reset on startup, not resetting again")

bellows/ezsp/protocol.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22

33
import abc
44
import asyncio
5+
from asyncio import timeout as asyncio_timeout
56
import binascii
7+
from collections.abc import AsyncGenerator, Callable, Iterable
68
import functools
79
import logging
8-
import sys
910
import time
10-
from typing import TYPE_CHECKING, Any, AsyncGenerator, Callable, Iterable
11-
12-
import zigpy.state
13-
14-
if sys.version_info[:2] < (3, 11):
15-
from async_timeout import timeout as asyncio_timeout # pragma: no cover
16-
else:
17-
from asyncio import timeout as asyncio_timeout # pragma: no cover
11+
from typing import TYPE_CHECKING, Any
1812

1913
from zigpy.datastructures import PriorityDynamicBoundedSemaphore
14+
import zigpy.state
2015

2116
from bellows.config import CONF_EZSP_POLICIES
2217
from bellows.exception import InvalidCommandError

bellows/ezsp/v13/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
""""EZSP Protocol version 13 protocol handler."""
22
from __future__ import annotations
33

4+
from collections.abc import AsyncGenerator, Iterable
45
import logging
5-
from typing import AsyncGenerator, Iterable
66

77
import voluptuous as vol
88
from zigpy.exceptions import NetworkNotFormed

bellows/ezsp/v14/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""""EZSP Protocol version 14 protocol handler."""
22
from __future__ import annotations
33

4-
from typing import AsyncGenerator
4+
from collections.abc import AsyncGenerator
55

66
import voluptuous as vol
77
from zigpy.exceptions import NetworkNotFormed

bellows/ezsp/v4/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
""""EZSP Protocol version 4 command."""
22
from __future__ import annotations
33

4+
from collections.abc import AsyncGenerator, Iterable
45
import logging
56
import random
6-
from typing import AsyncGenerator, Iterable
77

88
import voluptuous as vol
99
import zigpy.state
@@ -189,11 +189,11 @@ async def set_source_route(self, nwk: t.NWK, relays: list[t.NWK]) -> t.sl_Status
189189

190190
async def read_counters(self) -> dict[t.EmberCounterType, t.uint16_t]:
191191
(res,) = await self.readCounters()
192-
return dict(zip(t.EmberCounterType, res))
192+
return dict(zip(t.EmberCounterType, res, strict=False))
193193

194194
async def read_and_clear_counters(self) -> dict[t.EmberCounterType, t.uint16_t]:
195195
(res,) = await self.readAndClearCounters()
196-
return dict(zip(t.EmberCounterType, res))
196+
return dict(zip(t.EmberCounterType, res, strict=False))
197197

198198
async def set_extended_timeout(
199199
self, nwk: t.NWK, ieee: t.EUI64, extended_timeout: bool = True

bellows/ezsp/v5/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
""""EZSP Protocol version 5 protocol handler."""
22
from __future__ import annotations
33

4+
from collections.abc import AsyncGenerator
45
import logging
5-
from typing import AsyncGenerator
66

77
import voluptuous as vol
88

bellows/ezsp/v7/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
""""EZSP Protocol version 7 protocol handler."""
22
from __future__ import annotations
33

4+
from collections.abc import AsyncGenerator
45
import logging
5-
from typing import AsyncGenerator
66

77
import voluptuous
88

bellows/ezsp/v8/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
""""EZSP Protocol version 8 protocol handler."""
22
import asyncio
33
import logging
4-
from typing import Tuple
54

65
import voluptuous
76

@@ -30,7 +29,7 @@ def _ezsp_frame_tx(self, name: str) -> bytes:
3029
hdr = [self._seq, 0x00, 0x01]
3130
return bytes(hdr) + t.uint16_t(cmd_id).serialize()
3231

33-
def _ezsp_frame_rx(self, data: bytes) -> Tuple[int, int, bytes]:
32+
def _ezsp_frame_rx(self, data: bytes) -> tuple[int, int, bytes]:
3433
"""Handler for received data frame."""
3534
seq, data = data[0], data[3:]
3635
frame_id, data = t.uint16_t.deserialize(data)

0 commit comments

Comments
 (0)