Bump pre-commit ruff to 0.5.7 and reformat (#5242)

It seems that the codebase is not formatted with the latest ruff
version. This PR reformats the codebase with ruff 0.5.7.
This commit is contained in:
Stefan Agner 2024-08-13 20:53:56 +02:00 committed by GitHub
parent 21ae2c2e54
commit f6faa18409
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
304 changed files with 1173 additions and 617 deletions

View File

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.5.7
hooks:
- id: ruff
args:

View File

@ -228,7 +228,7 @@ filterwarnings = [
]
[tool.ruff]
select = [
lint.select = [
"B002", # Python does not support the unary prefix increment
"B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception
@ -291,7 +291,7 @@ select = [
"W", # pycodestyle
]
ignore = [
lint.ignore = [
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
@ -338,16 +338,16 @@ ignore = [
"PLE0605",
]
[tool.ruff.flake8-import-conventions.extend-aliases]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
voluptuous = "vol"
[tool.ruff.flake8-pytest-style]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
[tool.ruff.flake8-tidy-imports.banned-api]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pytz".msg = "use zoneinfo instead"
[tool.ruff.isort]
[tool.ruff.lint.isort]
force-sort-within-sections = true
section-order = [
"future",
@ -361,10 +361,10 @@ known-first-party = ["supervisor", "tests"]
combine-as-imports = true
split-on-trailing-comma = false
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# DBus Service Mocks must use typing and names understood by dbus-fast
"tests/dbus_service_mocks/*.py" = ["F722", "F821", "N815"]
[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 25

View File

@ -1,4 +1,5 @@
"""Home Assistant Supervisor setup."""
from pathlib import Path
import re

View File

@ -1,4 +1,5 @@
"""Main file for Supervisor."""
import asyncio
from concurrent.futures import ThreadPoolExecutor
import logging

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor add-ons."""
import asyncio
from collections.abc import Awaitable
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Supervisor add-on build environment."""
from __future__ import annotations
from functools import cached_property

View File

@ -1,4 +1,5 @@
"""Add-on static data."""
from datetime import timedelta
from enum import StrEnum

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor add-on data."""
from copy import deepcopy
from typing import Any

View File

@ -1,4 +1,5 @@
"""Supervisor add-on manager."""
import asyncio
from collections.abc import Awaitable
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor add-ons."""
from abc import ABC, abstractmethod
from collections import defaultdict
from collections.abc import Awaitable, Callable

View File

@ -1,4 +1,5 @@
"""Add-on Options / UI rendering."""
import hashlib
import logging
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Util add-ons functions."""
from __future__ import annotations
import asyncio

View File

@ -1,4 +1,5 @@
"""Validate add-ons options schema."""
import logging
import re
import secrets

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Audio RESTful API."""
import asyncio
from collections.abc import Awaitable
from dataclasses import asdict

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor auth/SSO RESTful API."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Backups RESTful API."""
import asyncio
from collections.abc import Callable
import errno
@ -342,9 +343,9 @@ class APIBackups(CoreSysAttributes):
_LOGGER.info("Downloading backup %s", backup.slug)
response = web.FileResponse(backup.tarfile)
response.content_type = CONTENT_TYPE_TAR
response.headers[
CONTENT_DISPOSITION
] = f"attachment; filename={RE_SLUGIFY_NAME.sub('_', backup.name)}.tar"
response.headers[CONTENT_DISPOSITION] = (
f"attachment; filename={RE_SLUGIFY_NAME.sub('_', backup.name)}.tar"
)
return response
@api_process

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor HA cli RESTful API."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor network RESTful API."""
import logging
import voluptuous as vol

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor DNS RESTful API."""
import asyncio
from collections.abc import Awaitable
import logging

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Home Assistant RESTful API."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor hardware RESTful API."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Supervisor Add-on ingress service."""
import asyncio
from ipaddress import ip_address
import logging

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Jobs RESTful API."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Multicast RESTful API."""
import asyncio
from collections.abc import Awaitable
import logging

View File

@ -1,4 +1,5 @@
"""REST API for network."""
import asyncio
from collections.abc import Awaitable
from dataclasses import replace

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Observer RESTful API."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor HassOS RESTful API."""
import asyncio
from collections.abc import Awaitable
import logging

View File

@ -1,4 +1,5 @@
"""Utils for Home Assistant Proxy."""
import asyncio
from contextlib import asynccontextmanager
import logging

View File

@ -1,4 +1,5 @@
"""Handle REST API for resoulution."""
import asyncio
from collections.abc import Awaitable
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Root RESTful API."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Security RESTful API."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Home Assistant RESTful API."""
import asyncio
from collections.abc import Awaitable
from typing import Any

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Supervisor RESTful API."""
import asyncio
from collections.abc import Awaitable
import logging

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor util for RESTful API."""
import json
from typing import Any

View File

@ -1,4 +1,5 @@
"""Handle Arch for underlay maschine/platforms."""
import logging
from pathlib import Path
import platform

View File

@ -1,4 +1,5 @@
"""Manage SSO for Add-ons with Home Assistant user."""
import asyncio
import hashlib
import logging

View File

@ -1,4 +1,5 @@
"""Representation of a backup file."""
import asyncio
from base64 import b64decode, b64encode
from collections import defaultdict

View File

@ -1,4 +1,5 @@
"""Backup consts."""
from enum import StrEnum
BUF_SIZE = 2**20 * 4 # 4MB

View File

@ -1,4 +1,5 @@
"""Util add-on functions."""
import hashlib
import re

View File

@ -1,4 +1,5 @@
"""Validate some things around restore."""
from __future__ import annotations
from typing import Any

View File

@ -1,4 +1,6 @@
"""Bootstrap Supervisor."""
# ruff: noqa: T100
import logging
import os
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Bus event system."""
from __future__ import annotations
from collections.abc import Awaitable, Callable

View File

@ -1,4 +1,5 @@
"""Bootstrap Supervisor."""
from datetime import UTC, datetime
import logging
import os

View File

@ -1,4 +1,5 @@
"""Constants file for Supervisor."""
from dataclasses import dataclass
from enum import StrEnum
from ipaddress import ip_network

View File

@ -1,4 +1,5 @@
"""Main file for Supervisor."""
import asyncio
from collections.abc import Awaitable
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Handle core shared data."""
from __future__ import annotations
import asyncio

View File

@ -1,4 +1,5 @@
"""OS-Agent implementation for DBUS."""
import asyncio
from collections.abc import Awaitable
import logging

View File

@ -1,4 +1,5 @@
"""AppArmor object for OS-Agent."""
from pathlib import Path
from awesomeversion import AwesomeVersion

View File

@ -1,4 +1,5 @@
"""Board management for OS Agent."""
import logging
from dbus_fast.aio.message_bus import MessageBus

View File

@ -1,4 +1,5 @@
"""DataDisk object for OS-Agent."""
from pathlib import Path
from ..const import (

View File

@ -1,4 +1,5 @@
"""Constants for DBUS."""
from enum import IntEnum, StrEnum
from socket import AF_INET, AF_INET6

View File

@ -1,4 +1,5 @@
"""D-Bus interface for hostname."""
import logging
from dbus_fast.aio.message_bus import MessageBus

View File

@ -1,4 +1,5 @@
"""Interface class for D-Bus wrappers."""
from abc import ABC
from collections.abc import Callable
from functools import wraps

View File

@ -1,4 +1,5 @@
"""Interface to Logind over D-Bus."""
import logging
from dbus_fast.aio.message_bus import MessageBus

View File

@ -1,4 +1,5 @@
"""D-Bus interface objects."""
import asyncio
import logging

View File

@ -1,4 +1,5 @@
"""Network Manager implementation for DBUS."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""NetworkConnection objects for Network Manager."""
from dataclasses import dataclass
from ipaddress import IPv4Address, IPv6Address

View File

@ -1,4 +1,5 @@
"""Network Manager DNS Manager object."""
from ipaddress import ip_address
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Connection object for Network Manager."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Payload generators for DBUS communication."""
from __future__ import annotations
import socket

View File

@ -1,4 +1,5 @@
"""Network Manager implementation for DBUS."""
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Wireless object for Network Manager."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""D-Bus interface for systemd-resolved."""
from __future__ import annotations
import logging

View File

@ -1,4 +1,5 @@
"""Interface to systemd-timedate over D-Bus."""
from datetime import datetime
import logging

View File

@ -1,4 +1,5 @@
"""Interface to UDisks2 over D-Bus."""
import asyncio
import logging
from typing import Any

View File

@ -1,4 +1,5 @@
"""Interface to UDisks2 Block Device over D-Bus."""
import asyncio
from collections.abc import Callable
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Handle discover message for Home Assistant."""
from __future__ import annotations
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor add-on Docker object."""
from __future__ import annotations
from collections.abc import Awaitable

View File

@ -1,4 +1,5 @@
"""Audio docker object."""
import logging
import docker

View File

@ -1,4 +1,5 @@
"""HA Cli docker object."""
import logging
from ..coresys import CoreSysAttributes

View File

@ -1,4 +1,5 @@
"""Docker constants."""
from enum import StrEnum
from docker.types import Mount

View File

@ -1,4 +1,5 @@
"""DNS docker object."""
import logging
from docker.types import Mount

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Docker object."""
from collections.abc import Awaitable
from ipaddress import IPv4Address
import logging

View File

@ -1,4 +1,5 @@
"""Interface class for Supervisor Docker object."""
from __future__ import annotations
from collections import defaultdict

View File

@ -1,4 +1,5 @@
"""Manager for Supervisor Docker."""
from contextlib import suppress
from ipaddress import IPv4Address
import logging

View File

@ -1,4 +1,5 @@
"""HA Cli docker object."""
import logging
from ..coresys import CoreSysAttributes

View File

@ -1,4 +1,5 @@
"""Internal network manager for Supervisor."""
from contextlib import suppress
from ipaddress import IPv4Address
import logging

View File

@ -1,4 +1,5 @@
"""Observer docker object."""
import logging
from ..const import DOCKER_NETWORK_MASK

View File

@ -1,4 +1,5 @@
"""Calc and represent docker stats data."""
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Init file for Supervisor Docker object."""
from collections.abc import Awaitable
from ipaddress import IPv4Address
import logging

View File

@ -1,4 +1,5 @@
"""Constants for hardware."""
from enum import StrEnum

View File

@ -1,4 +1,5 @@
"""Data representation of Hardware."""
from __future__ import annotations
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Read disk hardware info from system."""
import logging
from pathlib import Path
import shutil

View File

@ -1,4 +1,5 @@
"""Read hardware info from system."""
from datetime import UTC, datetime
import logging
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Hardware Manager of Supervisor."""
import logging
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Supervisor Hardware monitor based on udev."""
import asyncio
import logging
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Policy / cgroups management of local host."""
import logging
from ..coresys import CoreSys, CoreSysAttributes

View File

@ -1,4 +1,5 @@
"""Home Assistant control object."""
import asyncio
from contextlib import AbstractAsyncContextManager, asynccontextmanager, suppress
from dataclasses import dataclass

View File

@ -1,4 +1,5 @@
"""Constants for homeassistant."""
from datetime import timedelta
from enum import StrEnum
from pathlib import PurePath

View File

@ -1,4 +1,5 @@
"""Home Assistant control object."""
import asyncio
from collections.abc import Awaitable
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Handle Home Assistant secrets to add-ons."""
from datetime import timedelta
import logging
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Validate functions."""
import uuid
import voluptuous as vol

View File

@ -1,4 +1,5 @@
"""Home Assistant Websocket API."""
from __future__ import annotations
import asyncio

View File

@ -1,4 +1,5 @@
"""AppArmor control for host."""
from __future__ import annotations
from contextlib import suppress

View File

@ -1,4 +1,5 @@
"""Const for host."""
from enum import StrEnum
PARAM_BOOT_ID = "_BOOT_ID"

View File

@ -1,4 +1,5 @@
"""Power control for host."""
from datetime import datetime
import logging

View File

@ -1,4 +1,5 @@
"""Info control for host."""
import asyncio
from datetime import datetime
import logging

View File

@ -1,4 +1,5 @@
"""Logs control for host."""
from __future__ import annotations
from contextlib import asynccontextmanager

View File

@ -1,4 +1,5 @@
"""Host function like audio, D-Bus or systemd."""
from contextlib import suppress
from functools import lru_cache
import logging

View File

@ -1,4 +1,5 @@
"""Info control for host."""
import asyncio
from contextlib import suppress
import logging

Some files were not shown because too many files have changed in this diff Show More