diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 466aa837edd..6bf44f9980b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -87,7 +87,7 @@ jobs: - name: Run black run: | . venv/bin/activate - black --target-version py38 --check supervisor tests setup.py + black --target-version py311 --check supervisor tests setup.py lint-dockerfile: name: Check Dockerfile diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85ce19bd48d..b4cf85099a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - --safe - --quiet - --target-version - - py310 + - py311 files: ^((supervisor|tests)/.+)?[^/]+\.py$ - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 @@ -31,4 +31,4 @@ repos: rev: v3.15.0 hooks: - id: pyupgrade - args: [--py310-plus] + args: [--py311-plus] diff --git a/supervisor/addons/addon.py b/supervisor/addons/addon.py index d7481de9c14..71330685bcd 100644 --- a/supervisor/addons/addon.py +++ b/supervisor/addons/addon.py @@ -555,7 +555,7 @@ async def watchdog_application(self) -> bool: ) as req: if req.status < 300: return True - except (asyncio.TimeoutError, aiohttp.ClientError): + except (TimeoutError, aiohttp.ClientError): pass return False @@ -861,7 +861,7 @@ async def _wait_for_startup(self) -> None: try: self._startup_task = self.sys_create_task(self._startup_event.wait()) await asyncio.wait_for(self._startup_task, STARTUP_TIMEOUT) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning( "Timeout while waiting for addon %s to start, took more than %s seconds", self.name, diff --git a/supervisor/api/proxy.py b/supervisor/api/proxy.py index 74a9346a815..e2e1f73452e 100644 --- a/supervisor/api/proxy.py +++ b/supervisor/api/proxy.py @@ -77,7 +77,7 @@ async def _api_client(self, request: web.Request, path: str, timeout: int = 300) _LOGGER.error("Error on API for request %s", path) except aiohttp.ClientError as err: _LOGGER.error("Client error on API %s request %s", path, err) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.error("Client timeout error on API request %s", path) raise HTTPBadGateway() diff --git a/supervisor/backups/manager.py b/supervisor/backups/manager.py index 764fc984c56..aebd7105b30 100644 --- a/supervisor/backups/manager.py +++ b/supervisor/backups/manager.py @@ -605,7 +605,7 @@ async def _thaw_all( try: try: await asyncio.wait_for(self._thaw_event.wait(), timeout) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning( "Timeout waiting for signal to thaw after manual freeze, beginning thaw now" ) diff --git a/supervisor/core.py b/supervisor/core.py index 47f8fd7abe6..6f3cfd79cca 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -309,7 +309,7 @@ async def stop(self): ) ] ) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning("Stage 1: Force Shutdown!") # Stage 2 @@ -326,7 +326,7 @@ async def stop(self): ) ] ) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.warning("Stage 2: Force Shutdown!") self.state = CoreState.CLOSE diff --git a/supervisor/dbus/udisks2/data.py b/supervisor/dbus/udisks2/data.py index 0305295c2b4..054f3feb556 100644 --- a/supervisor/dbus/udisks2/data.py +++ b/supervisor/dbus/udisks2/data.py @@ -3,10 +3,9 @@ from dataclasses import dataclass from inspect import get_annotations from pathlib import Path -from typing import Any, TypedDict +from typing import Any, NotRequired, TypedDict from dbus_fast import Variant -from typing_extensions import NotRequired from .const import EncryptType, EraseMode diff --git a/supervisor/homeassistant/api.py b/supervisor/homeassistant/api.py index b0d099b1c87..9e0728f7277 100644 --- a/supervisor/homeassistant/api.py +++ b/supervisor/homeassistant/api.py @@ -107,7 +107,7 @@ async def make_request( continue yield resp return - except (asyncio.TimeoutError, aiohttp.ClientError) as err: + except (TimeoutError, aiohttp.ClientError) as err: _LOGGER.error("Error on call %s: %s", url, err) break diff --git a/supervisor/misc/scheduler.py b/supervisor/misc/scheduler.py index fa986d332d5..a8583161fc7 100644 --- a/supervisor/misc/scheduler.py +++ b/supervisor/misc/scheduler.py @@ -115,5 +115,5 @@ async def shutdown(self, timeout=10) -> None: try: async with async_timeout.timeout(timeout): await asyncio.wait(running) - except asyncio.TimeoutError: + except TimeoutError: _LOGGER.error("Timeout while waiting for jobs shutdown") diff --git a/supervisor/mounts/validate.py b/supervisor/mounts/validate.py index 5a61e8ed6a3..16c8f493a8d 100644 --- a/supervisor/mounts/validate.py +++ b/supervisor/mounts/validate.py @@ -1,9 +1,8 @@ """Validation for mount manager.""" import re -from typing import TypedDict +from typing import NotRequired, TypedDict -from typing_extensions import NotRequired import voluptuous as vol from ..const import ( diff --git a/supervisor/os/manager.py b/supervisor/os/manager.py index 814a88be860..6a8867d5dd4 100644 --- a/supervisor/os/manager.py +++ b/supervisor/os/manager.py @@ -1,5 +1,4 @@ """OS support on supervisor.""" -import asyncio from collections.abc import Awaitable import logging from pathlib import Path @@ -114,7 +113,7 @@ async def _download_raucb(self, url: str, raucb: Path) -> None: _LOGGER.info("Completed download of OTA update file %s", raucb) - except (aiohttp.ClientError, asyncio.TimeoutError) as err: + except (aiohttp.ClientError, TimeoutError) as err: self.sys_supervisor.connectivity = False raise HassOSUpdateError( f"Can't fetch OTA update from {url}: {err!s}", _LOGGER.error diff --git a/supervisor/plugins/observer.py b/supervisor/plugins/observer.py index 6d64ede65fa..b78d011fe53 100644 --- a/supervisor/plugins/observer.py +++ b/supervisor/plugins/observer.py @@ -139,7 +139,7 @@ async def check_system_runtime(self) -> bool: ) as request: if request.status == 200: return True - except (aiohttp.ClientError, asyncio.TimeoutError): + except (aiohttp.ClientError, TimeoutError): pass return False diff --git a/supervisor/supervisor.py b/supervisor/supervisor.py index 18619cca11d..34ed9df9776 100644 --- a/supervisor/supervisor.py +++ b/supervisor/supervisor.py @@ -1,5 +1,4 @@ """Home Assistant control object.""" -import asyncio from collections.abc import Awaitable from contextlib import suppress from datetime import timedelta @@ -129,7 +128,7 @@ async def update_apparmor(self) -> None: ) data = await request.text() - except (aiohttp.ClientError, asyncio.TimeoutError) as err: + except (aiohttp.ClientError, TimeoutError) as err: self.sys_supervisor.connectivity = False raise SupervisorAppArmorError( f"Can't fetch AppArmor profile {url}: {str(err) or 'Timeout'}", @@ -270,7 +269,7 @@ async def check_connectivity(self): await self.sys_websession.head( "https://checkonline.home-assistant.io/online.txt", timeout=timeout ) - except (ClientError, asyncio.TimeoutError): + except (ClientError, TimeoutError): self.connectivity = False else: self.connectivity = True diff --git a/supervisor/updater.py b/supervisor/updater.py index cee2b6b8a6a..47571fc031e 100644 --- a/supervisor/updater.py +++ b/supervisor/updater.py @@ -1,5 +1,4 @@ """Fetch last versions from webserver.""" -import asyncio from contextlib import suppress from datetime import timedelta import json @@ -207,7 +206,7 @@ async def fetch_data(self): ) data = await request.read() - except (aiohttp.ClientError, asyncio.TimeoutError) as err: + except (aiohttp.ClientError, TimeoutError) as err: self.sys_supervisor.connectivity = False raise UpdaterError( f"Can't fetch versions from {url}: {str(err) or 'Timeout'}", diff --git a/supervisor/utils/codenotary.py b/supervisor/utils/codenotary.py index 9b116f6c45c..bebd6bc7c9e 100644 --- a/supervisor/utils/codenotary.py +++ b/supervisor/utils/codenotary.py @@ -69,7 +69,7 @@ async def cas_validate( async with async_timeout.timeout(15): data, error = await proc.communicate() - except asyncio.TimeoutError: + except TimeoutError: raise CodeNotaryBackendError( "Timeout while processing CodeNotary", _LOGGER.warning ) from None diff --git a/supervisor/utils/dbus.py b/supervisor/utils/dbus.py index 05bc70fa078..864b6107969 100644 --- a/supervisor/utils/dbus.py +++ b/supervisor/utils/dbus.py @@ -126,7 +126,7 @@ async def introspect(self) -> Node: raise DBusParseError( f"Can't parse introspect data: {err}", _LOGGER.error ) from err - except (EOFError, asyncio.TimeoutError): + except (EOFError, TimeoutError): _LOGGER.warning( "Busy system at %s - %s", self.bus_name, self.object_path ) diff --git a/supervisor/utils/pwned.py b/supervisor/utils/pwned.py index ea8663a8ab1..7c2250154f3 100644 --- a/supervisor/utils/pwned.py +++ b/supervisor/utils/pwned.py @@ -1,5 +1,4 @@ """Small wrapper for haveibeenpwned.com API.""" -import asyncio import io import logging @@ -40,7 +39,7 @@ async def check_pwned_password(websession: aiohttp.ClientSession, sha1_pw: str) _CACHE.add(sha1_short) raise PwnedSecret() - except (aiohttp.ClientError, asyncio.TimeoutError) as err: + except (aiohttp.ClientError, TimeoutError) as err: raise PwnedConnectivityError( f"Can't fetch HIBP data: {str(err) or 'Timeout'}", _LOGGER.warning ) from err diff --git a/supervisor/utils/whoami.py b/supervisor/utils/whoami.py index b47fa5eb85b..edb285395c2 100644 --- a/supervisor/utils/whoami.py +++ b/supervisor/utils/whoami.py @@ -2,7 +2,6 @@ https://github.com/home-assistant/whoami.home-assistant.io """ -import asyncio from datetime import datetime import logging @@ -51,7 +50,7 @@ async def retrieve_whoami( f"Whoami service failed with SSL verification: {err!s}", _LOGGER.warning ) from err - except (aiohttp.ClientError, asyncio.TimeoutError) as err: + except (aiohttp.ClientError, TimeoutError) as err: raise WhoamiConnectivityError( f"Can't fetch Whoami data: {str(err) or 'Timeout'}", _LOGGER.warning ) from err diff --git a/tox.ini b/tox.ini index f2ae143330a..23a28f73420 100644 --- a/tox.ini +++ b/tox.ini @@ -21,4 +21,4 @@ commands = [testenv:black] basepython = python3 commands = - black --target-version py39 --check supervisor tests setup.py + black --target-version py311 --check supervisor tests setup.py