Bump tooling to target Python version 3.11 (#4666)

This commit is contained in:
Stefan Agner 2023-11-03 12:02:55 +01:00 committed by GitHub
parent a0c12e7228
commit 38d5d2307f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 23 additions and 30 deletions

View File

@ -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

View File

@ -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]

View File

@ -555,7 +555,7 @@ class Addon(AddonModel):
) as req:
if req.status < 300:
return True
except (asyncio.TimeoutError, aiohttp.ClientError):
except (TimeoutError, aiohttp.ClientError):
pass
return False
@ -861,7 +861,7 @@ class Addon(AddonModel):
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,

View File

@ -77,7 +77,7 @@ class APIProxy(CoreSysAttributes):
_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()

View File

@ -605,7 +605,7 @@ class BackupManager(FileConfiguration, JobGroup):
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"
)

View File

@ -309,7 +309,7 @@ class Core(CoreSysAttributes):
)
]
)
except asyncio.TimeoutError:
except TimeoutError:
_LOGGER.warning("Stage 1: Force Shutdown!")
# Stage 2
@ -326,7 +326,7 @@ class Core(CoreSysAttributes):
)
]
)
except asyncio.TimeoutError:
except TimeoutError:
_LOGGER.warning("Stage 2: Force Shutdown!")
self.state = CoreState.CLOSE

View File

@ -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

View File

@ -107,7 +107,7 @@ class HomeAssistantAPI(CoreSysAttributes):
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

View File

@ -115,5 +115,5 @@ class Scheduler(CoreSysAttributes):
try:
async with async_timeout.timeout(timeout):
await asyncio.wait(running)
except asyncio.TimeoutError:
except TimeoutError:
_LOGGER.error("Timeout while waiting for jobs shutdown")

View File

@ -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 (

View File

@ -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 @@ class OSManager(CoreSysAttributes):
_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

View File

@ -139,7 +139,7 @@ class PluginObserver(PluginBase):
) as request:
if request.status == 200:
return True
except (aiohttp.ClientError, asyncio.TimeoutError):
except (aiohttp.ClientError, TimeoutError):
pass
return False

View File

@ -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 @@ class Supervisor(CoreSysAttributes):
)
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 @@ class Supervisor(CoreSysAttributes):
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

View File

@ -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 @@ class Updater(FileConfiguration, CoreSysAttributes):
)
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'}",

View File

@ -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

View File

@ -126,7 +126,7 @@ class DBus:
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
)

View File

@ -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

View File

@ -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

View File

@ -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