Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump tooling to target Python version 3.11 #4666

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,4 +31,4 @@ repos:
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py310-plus]
args: [--py311-plus]
4 changes: 2 additions & 2 deletions supervisor/addons/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion supervisor/api/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion supervisor/backups/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions supervisor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async def stop(self):
)
]
)
except asyncio.TimeoutError:
except TimeoutError:
_LOGGER.warning("Stage 1: Force Shutdown!")

# Stage 2
Expand All @@ -326,7 +326,7 @@ async def stop(self):
)
]
)
except asyncio.TimeoutError:
except TimeoutError:
_LOGGER.warning("Stage 2: Force Shutdown!")

self.state = CoreState.CLOSE
Expand Down
3 changes: 1 addition & 2 deletions supervisor/dbus/udisks2/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion supervisor/homeassistant/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion supervisor/misc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
3 changes: 1 addition & 2 deletions supervisor/mounts/validate.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions supervisor/os/manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""OS support on supervisor."""
import asyncio
from collections.abc import Awaitable
import logging
from pathlib import Path
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion supervisor/plugins/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions supervisor/supervisor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Home Assistant control object."""
import asyncio
from collections.abc import Awaitable
from contextlib import suppress
from datetime import timedelta
Expand Down Expand Up @@ -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'}",
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions supervisor/updater.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Fetch last versions from webserver."""
import asyncio
from contextlib import suppress
from datetime import timedelta
import json
Expand Down Expand Up @@ -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'}",
Expand Down
2 changes: 1 addition & 1 deletion supervisor/utils/codenotary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion supervisor/utils/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
3 changes: 1 addition & 2 deletions supervisor/utils/pwned.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Small wrapper for haveibeenpwned.com API."""
import asyncio
import io
import logging

Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions supervisor/utils/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

https://github.com/home-assistant/whoami.home-assistant.io
"""
import asyncio
from datetime import datetime
import logging

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading