Skip to content

Commit af04a7c

Browse files
committed
Drop Python 3.9 and 3.10 compat
1 parent b3448b9 commit af04a7c

File tree

17 files changed

+45
-88
lines changed

17 files changed

+45
-88
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/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/xncp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Custom EZSP commands."""
22
from __future__ import annotations
33

4+
from collections.abc import Callable
45
import dataclasses
56
import logging
6-
from typing import Callable
77

88
import zigpy.types as t
99

bellows/thread.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from concurrent.futures import ThreadPoolExecutor
33
import functools
44
import logging
5-
import sys
65

76
LOGGER = logging.getLogger(__name__)
87

@@ -35,10 +34,7 @@ async def start(self):
3534
if self.loop is not None and not self.loop.is_closed():
3635
return
3736

38-
executor_opts = {"max_workers": 1}
39-
if sys.version_info[:2] >= (3, 6):
40-
executor_opts["thread_name_prefix"] = __name__
41-
executor = ThreadPoolExecutor(**executor_opts)
37+
executor = ThreadPoolExecutor(max_workers=1, thread_name_prefix=__name__)
4238

4339
thread_started_future = current_loop.create_future()
4440

bellows/types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def deserialize_dict(data, schema):
1313

1414
def serialize_dict(args, kwargs, schema):
1515
params = {
16-
**dict(zip(schema.keys(), args)),
16+
**dict(zip(schema.keys(), args, strict=False)),
1717
**kwargs,
1818
}
1919

bellows/uart.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import asyncio
2+
from asyncio import timeout as asyncio_timeout
23
import logging
3-
import sys
4-
5-
if sys.version_info[:2] < (3, 11):
6-
from async_timeout import timeout as asyncio_timeout # pragma: no cover
7-
else:
8-
from asyncio import timeout as asyncio_timeout # pragma: no cover
94

105
import zigpy.config
116
import zigpy.serial

bellows/zigbee/application.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
from __future__ import annotations
22

33
import asyncio
4-
from datetime import datetime, timezone
4+
from asyncio import timeout as asyncio_timeout
5+
from collections.abc import AsyncGenerator
6+
from datetime import UTC, datetime
7+
import importlib.metadata
58
import logging
69
import os
710
import statistics
8-
import sys
9-
from typing import AsyncGenerator
10-
11-
if sys.version_info[:2] < (3, 11):
12-
from async_timeout import timeout as asyncio_timeout # pragma: no cover
13-
else:
14-
from asyncio import timeout as asyncio_timeout # pragma: no cover
15-
16-
import importlib.metadata
1711

1812
import zigpy.application
1913
import zigpy.config
@@ -843,7 +837,7 @@ async def _packet_capture(self, channel: int):
843837
with self._ezsp.callback_for_commands(
844838
{"mfglibRxHandler"},
845839
callback=lambda _, response: queue.put_nowait(
846-
(datetime.now(timezone.utc), response)
840+
(datetime.now(UTC), response)
847841
),
848842
):
849843
while True:
@@ -1096,7 +1090,7 @@ async def _watchdog_feed(self):
10961090
cnt._last_reset_value = 0
10971091

10981092
LOGGER.debug("%s", counters)
1099-
except (asyncio.TimeoutError, EzspError) as exc:
1093+
except (TimeoutError, EzspError) as exc:
11001094
# TODO: converted Silvercrest gateways break without this
11011095
LOGGER.warning("Watchdog heartbeat timeout: %s", repr(exc))
11021096
self._watchdog_failures += 1

0 commit comments

Comments
 (0)