1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 14:43:51 +00:00

Drop Python 3.10 support, require Python 3.11+ (#9522)

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2025-07-15 15:20:58 -10:00
committed by GitHub
parent 30c4b91697
commit f745135bdc
36 changed files with 61 additions and 72 deletions

View File

@@ -76,6 +76,7 @@ async def theme_to_code(config):
for w_name, style in theme.items():
# Work around Python 3.10 bug with nested async comprehensions
# With Python 3.11 this could be simplified
# TODO: Now that we require Python 3.11+, this can be updated to use nested comprehensions
styles = {}
for part, states in collect_parts(style).items():
styles[part] = {

View File

@@ -3,15 +3,9 @@ from __future__ import annotations
import asyncio
from contextlib import suppress
from ipaddress import ip_address
import sys
from icmplib import NameLookupError, async_resolve
if sys.version_info >= (3, 11):
from asyncio import timeout as async_timeout
else:
from async_timeout import timeout as async_timeout
RESOLVE_TIMEOUT = 3.0
@@ -20,9 +14,9 @@ async def _async_resolve_wrapper(hostname: str) -> list[str] | Exception:
with suppress(ValueError):
return [str(ip_address(hostname))]
try:
async with async_timeout(RESOLVE_TIMEOUT):
async with asyncio.timeout(RESOLVE_TIMEOUT):
return await async_resolve(hostname)
except (asyncio.TimeoutError, NameLookupError, UnicodeError) as ex:
except (TimeoutError, NameLookupError, UnicodeError) as ex:
return ex