mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-16 13:46:31 +00:00
Bump tooling to target Python version 3.11 (#4666)
This commit is contained in:
parent
a0c12e7228
commit
38d5d2307f
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -87,7 +87,7 @@ jobs:
|
|||||||
- name: Run black
|
- name: Run black
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
black --target-version py38 --check supervisor tests setup.py
|
black --target-version py311 --check supervisor tests setup.py
|
||||||
|
|
||||||
lint-dockerfile:
|
lint-dockerfile:
|
||||||
name: Check Dockerfile
|
name: Check Dockerfile
|
||||||
|
@ -7,7 +7,7 @@ repos:
|
|||||||
- --safe
|
- --safe
|
||||||
- --quiet
|
- --quiet
|
||||||
- --target-version
|
- --target-version
|
||||||
- py310
|
- py311
|
||||||
files: ^((supervisor|tests)/.+)?[^/]+\.py$
|
files: ^((supervisor|tests)/.+)?[^/]+\.py$
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 6.0.0
|
rev: 6.0.0
|
||||||
@ -31,4 +31,4 @@ repos:
|
|||||||
rev: v3.15.0
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py310-plus]
|
args: [--py311-plus]
|
||||||
|
@ -555,7 +555,7 @@ class Addon(AddonModel):
|
|||||||
) as req:
|
) as req:
|
||||||
if req.status < 300:
|
if req.status < 300:
|
||||||
return True
|
return True
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (TimeoutError, aiohttp.ClientError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@ -861,7 +861,7 @@ class Addon(AddonModel):
|
|||||||
try:
|
try:
|
||||||
self._startup_task = self.sys_create_task(self._startup_event.wait())
|
self._startup_task = self.sys_create_task(self._startup_event.wait())
|
||||||
await asyncio.wait_for(self._startup_task, STARTUP_TIMEOUT)
|
await asyncio.wait_for(self._startup_task, STARTUP_TIMEOUT)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Timeout while waiting for addon %s to start, took more than %s seconds",
|
"Timeout while waiting for addon %s to start, took more than %s seconds",
|
||||||
self.name,
|
self.name,
|
||||||
|
@ -77,7 +77,7 @@ class APIProxy(CoreSysAttributes):
|
|||||||
_LOGGER.error("Error on API for request %s", path)
|
_LOGGER.error("Error on API for request %s", path)
|
||||||
except aiohttp.ClientError as err:
|
except aiohttp.ClientError as err:
|
||||||
_LOGGER.error("Client error on API %s request %s", path, 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)
|
_LOGGER.error("Client timeout error on API request %s", path)
|
||||||
|
|
||||||
raise HTTPBadGateway()
|
raise HTTPBadGateway()
|
||||||
|
@ -605,7 +605,7 @@ class BackupManager(FileConfiguration, JobGroup):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self._thaw_event.wait(), timeout)
|
await asyncio.wait_for(self._thaw_event.wait(), timeout)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Timeout waiting for signal to thaw after manual freeze, beginning thaw now"
|
"Timeout waiting for signal to thaw after manual freeze, beginning thaw now"
|
||||||
)
|
)
|
||||||
|
@ -309,7 +309,7 @@ class Core(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
_LOGGER.warning("Stage 1: Force Shutdown!")
|
_LOGGER.warning("Stage 1: Force Shutdown!")
|
||||||
|
|
||||||
# Stage 2
|
# Stage 2
|
||||||
@ -326,7 +326,7 @@ class Core(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
_LOGGER.warning("Stage 2: Force Shutdown!")
|
_LOGGER.warning("Stage 2: Force Shutdown!")
|
||||||
|
|
||||||
self.state = CoreState.CLOSE
|
self.state = CoreState.CLOSE
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from inspect import get_annotations
|
from inspect import get_annotations
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, TypedDict
|
from typing import Any, NotRequired, TypedDict
|
||||||
|
|
||||||
from dbus_fast import Variant
|
from dbus_fast import Variant
|
||||||
from typing_extensions import NotRequired
|
|
||||||
|
|
||||||
from .const import EncryptType, EraseMode
|
from .const import EncryptType, EraseMode
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class HomeAssistantAPI(CoreSysAttributes):
|
|||||||
continue
|
continue
|
||||||
yield resp
|
yield resp
|
||||||
return
|
return
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
|
except (TimeoutError, aiohttp.ClientError) as err:
|
||||||
_LOGGER.error("Error on call %s: %s", url, err)
|
_LOGGER.error("Error on call %s: %s", url, err)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -115,5 +115,5 @@ class Scheduler(CoreSysAttributes):
|
|||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
await asyncio.wait(running)
|
await asyncio.wait(running)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
_LOGGER.error("Timeout while waiting for jobs shutdown")
|
_LOGGER.error("Timeout while waiting for jobs shutdown")
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
"""Validation for mount manager."""
|
"""Validation for mount manager."""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import TypedDict
|
from typing import NotRequired, TypedDict
|
||||||
|
|
||||||
from typing_extensions import NotRequired
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from ..const import (
|
from ..const import (
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""OS support on supervisor."""
|
"""OS support on supervisor."""
|
||||||
import asyncio
|
|
||||||
from collections.abc import Awaitable
|
from collections.abc import Awaitable
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -114,7 +113,7 @@ class OSManager(CoreSysAttributes):
|
|||||||
|
|
||||||
_LOGGER.info("Completed download of OTA update file %s", raucb)
|
_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
|
self.sys_supervisor.connectivity = False
|
||||||
raise HassOSUpdateError(
|
raise HassOSUpdateError(
|
||||||
f"Can't fetch OTA update from {url}: {err!s}", _LOGGER.error
|
f"Can't fetch OTA update from {url}: {err!s}", _LOGGER.error
|
||||||
|
@ -139,7 +139,7 @@ class PluginObserver(PluginBase):
|
|||||||
) as request:
|
) as request:
|
||||||
if request.status == 200:
|
if request.status == 200:
|
||||||
return True
|
return True
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError):
|
except (aiohttp.ClientError, TimeoutError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Home Assistant control object."""
|
"""Home Assistant control object."""
|
||||||
import asyncio
|
|
||||||
from collections.abc import Awaitable
|
from collections.abc import Awaitable
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -129,7 +128,7 @@ class Supervisor(CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
data = await request.text()
|
data = await request.text()
|
||||||
|
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
|
except (aiohttp.ClientError, TimeoutError) as err:
|
||||||
self.sys_supervisor.connectivity = False
|
self.sys_supervisor.connectivity = False
|
||||||
raise SupervisorAppArmorError(
|
raise SupervisorAppArmorError(
|
||||||
f"Can't fetch AppArmor profile {url}: {str(err) or 'Timeout'}",
|
f"Can't fetch AppArmor profile {url}: {str(err) or 'Timeout'}",
|
||||||
@ -270,7 +269,7 @@ class Supervisor(CoreSysAttributes):
|
|||||||
await self.sys_websession.head(
|
await self.sys_websession.head(
|
||||||
"https://checkonline.home-assistant.io/online.txt", timeout=timeout
|
"https://checkonline.home-assistant.io/online.txt", timeout=timeout
|
||||||
)
|
)
|
||||||
except (ClientError, asyncio.TimeoutError):
|
except (ClientError, TimeoutError):
|
||||||
self.connectivity = False
|
self.connectivity = False
|
||||||
else:
|
else:
|
||||||
self.connectivity = True
|
self.connectivity = True
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Fetch last versions from webserver."""
|
"""Fetch last versions from webserver."""
|
||||||
import asyncio
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import json
|
import json
|
||||||
@ -207,7 +206,7 @@ class Updater(FileConfiguration, CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
data = await request.read()
|
data = await request.read()
|
||||||
|
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
|
except (aiohttp.ClientError, TimeoutError) as err:
|
||||||
self.sys_supervisor.connectivity = False
|
self.sys_supervisor.connectivity = False
|
||||||
raise UpdaterError(
|
raise UpdaterError(
|
||||||
f"Can't fetch versions from {url}: {str(err) or 'Timeout'}",
|
f"Can't fetch versions from {url}: {str(err) or 'Timeout'}",
|
||||||
|
@ -69,7 +69,7 @@ async def cas_validate(
|
|||||||
|
|
||||||
async with async_timeout.timeout(15):
|
async with async_timeout.timeout(15):
|
||||||
data, error = await proc.communicate()
|
data, error = await proc.communicate()
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
raise CodeNotaryBackendError(
|
raise CodeNotaryBackendError(
|
||||||
"Timeout while processing CodeNotary", _LOGGER.warning
|
"Timeout while processing CodeNotary", _LOGGER.warning
|
||||||
) from None
|
) from None
|
||||||
|
@ -126,7 +126,7 @@ class DBus:
|
|||||||
raise DBusParseError(
|
raise DBusParseError(
|
||||||
f"Can't parse introspect data: {err}", _LOGGER.error
|
f"Can't parse introspect data: {err}", _LOGGER.error
|
||||||
) from err
|
) from err
|
||||||
except (EOFError, asyncio.TimeoutError):
|
except (EOFError, TimeoutError):
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Busy system at %s - %s", self.bus_name, self.object_path
|
"Busy system at %s - %s", self.bus_name, self.object_path
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Small wrapper for haveibeenpwned.com API."""
|
"""Small wrapper for haveibeenpwned.com API."""
|
||||||
import asyncio
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ async def check_pwned_password(websession: aiohttp.ClientSession, sha1_pw: str)
|
|||||||
_CACHE.add(sha1_short)
|
_CACHE.add(sha1_short)
|
||||||
raise PwnedSecret()
|
raise PwnedSecret()
|
||||||
|
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
|
except (aiohttp.ClientError, TimeoutError) as err:
|
||||||
raise PwnedConnectivityError(
|
raise PwnedConnectivityError(
|
||||||
f"Can't fetch HIBP data: {str(err) or 'Timeout'}", _LOGGER.warning
|
f"Can't fetch HIBP data: {str(err) or 'Timeout'}", _LOGGER.warning
|
||||||
) from err
|
) from err
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
https://github.com/home-assistant/whoami.home-assistant.io
|
https://github.com/home-assistant/whoami.home-assistant.io
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ async def retrieve_whoami(
|
|||||||
f"Whoami service failed with SSL verification: {err!s}", _LOGGER.warning
|
f"Whoami service failed with SSL verification: {err!s}", _LOGGER.warning
|
||||||
) from err
|
) from err
|
||||||
|
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
|
except (aiohttp.ClientError, TimeoutError) as err:
|
||||||
raise WhoamiConnectivityError(
|
raise WhoamiConnectivityError(
|
||||||
f"Can't fetch Whoami data: {str(err) or 'Timeout'}", _LOGGER.warning
|
f"Can't fetch Whoami data: {str(err) or 'Timeout'}", _LOGGER.warning
|
||||||
) from err
|
) from err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user