Skip to content

Commit

Permalink
Bump pre-commit ruff to 0.5.7 and reformat (#5242)
Browse files Browse the repository at this point in the history
It seems that the codebase is not formatted with the latest ruff
version. This PR reformats the codebase with ruff 0.5.7.
  • Loading branch information
agners authored Aug 13, 2024
1 parent 21ae2c2 commit f6faa18
Show file tree
Hide file tree
Showing 304 changed files with 1,173 additions and 617 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Home Assistant Supervisor setup."""

from pathlib import Path
import re

Expand Down
1 change: 1 addition & 0 deletions supervisor/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main file for Supervisor."""

import asyncio
from concurrent.futures import ThreadPoolExecutor
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/addon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor add-ons."""

import asyncio
from collections.abc import Awaitable
from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Supervisor add-on build environment."""

from __future__ import annotations

from functools import cached_property
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Add-on static data."""

from datetime import timedelta
from enum import StrEnum

Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor add-on data."""

from copy import deepcopy
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Supervisor add-on manager."""

import asyncio
from collections.abc import Awaitable
from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Add-on Options / UI rendering."""

import hashlib
import logging
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Util add-ons functions."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions supervisor/addons/validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Validate add-ons options schema."""

import logging
import re
import secrets
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/audio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Audio RESTful API."""

import asyncio
from collections.abc import Awaitable
from dataclasses import asdict
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor auth/SSO RESTful API."""

import asyncio
import logging
from typing import Any
Expand Down
7 changes: 4 additions & 3 deletions supervisor/api/backups.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Backups RESTful API."""

import asyncio
from collections.abc import Callable
import errno
Expand Down Expand Up @@ -342,9 +343,9 @@ async def download(self, request):
_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
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor HA cli RESTful API."""

import asyncio
import logging
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/discovery.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor network RESTful API."""

import logging

import voluptuous as vol
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/dns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor DNS RESTful API."""

import asyncio
from collections.abc import Awaitable
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/docker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Home Assistant RESTful API."""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions supervisor/api/hardware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor hardware RESTful API."""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions supervisor/api/ingress.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Supervisor Add-on ingress service."""

import asyncio
from ipaddress import ip_address
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/jobs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Jobs RESTful API."""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions supervisor/api/multicast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Multicast RESTful API."""

import asyncio
from collections.abc import Awaitable
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/network.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""REST API for network."""

import asyncio
from collections.abc import Awaitable
from dataclasses import replace
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/observer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Observer RESTful API."""

import asyncio
import logging
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/os.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor HassOS RESTful API."""

import asyncio
from collections.abc import Awaitable
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/proxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils for Home Assistant Proxy."""

import asyncio
from contextlib import asynccontextmanager
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/resolution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle REST API for resoulution."""

import asyncio
from collections.abc import Awaitable
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/root.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Root RESTful API."""

import asyncio
import logging
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/security.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Security RESTful API."""

import asyncio
import logging
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Home Assistant RESTful API."""

import asyncio
from collections.abc import Awaitable
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/supervisor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor Supervisor RESTful API."""

import asyncio
from collections.abc import Awaitable
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/api/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init file for Supervisor util for RESTful API."""

import json
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions supervisor/arch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle Arch for underlay maschine/platforms."""

import logging
from pathlib import Path
import platform
Expand Down
1 change: 1 addition & 0 deletions supervisor/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Manage SSO for Add-ons with Home Assistant user."""

import asyncio
import hashlib
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/backups/backup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Representation of a backup file."""

import asyncio
from base64 import b64decode, b64encode
from collections import defaultdict
Expand Down
1 change: 1 addition & 0 deletions supervisor/backups/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Backup consts."""

from enum import StrEnum

BUF_SIZE = 2**20 * 4 # 4MB
Expand Down
1 change: 1 addition & 0 deletions supervisor/backups/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Util add-on functions."""

import hashlib
import re

Expand Down
1 change: 1 addition & 0 deletions supervisor/backups/validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Validate some things around restore."""

from __future__ import annotations

from typing import Any
Expand Down
2 changes: 2 additions & 0 deletions supervisor/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Bootstrap Supervisor."""

# ruff: noqa: T100
import logging
import os
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions supervisor/bus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Bus event system."""

from __future__ import annotations

from collections.abc import Awaitable, Callable
Expand Down
1 change: 1 addition & 0 deletions supervisor/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Bootstrap Supervisor."""

from datetime import UTC, datetime
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions supervisor/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants file for Supervisor."""

from dataclasses import dataclass
from enum import StrEnum
from ipaddress import ip_network
Expand Down
1 change: 1 addition & 0 deletions supervisor/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main file for Supervisor."""

import asyncio
from collections.abc import Awaitable
from contextlib import suppress
Expand Down
1 change: 1 addition & 0 deletions supervisor/coresys.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle core shared data."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""OS-Agent implementation for DBUS."""

import asyncio
from collections.abc import Awaitable
import logging
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/agent/apparmor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""AppArmor object for OS-Agent."""

from pathlib import Path

from awesomeversion import AwesomeVersion
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/agent/boards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Board management for OS Agent."""

import logging

from dbus_fast.aio.message_bus import MessageBus
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/agent/datadisk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""DataDisk object for OS-Agent."""

from pathlib import Path

from ..const import (
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for DBUS."""

from enum import IntEnum, StrEnum
from socket import AF_INET, AF_INET6

Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/hostname.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""D-Bus interface for hostname."""

import logging

from dbus_fast.aio.message_bus import MessageBus
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface class for D-Bus wrappers."""

from abc import ABC
from collections.abc import Callable
from functools import wraps
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/logind.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface to Logind over D-Bus."""

import logging

from dbus_fast.aio.message_bus import MessageBus
Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""D-Bus interface objects."""

import asyncio
import logging

Expand Down
1 change: 1 addition & 0 deletions supervisor/dbus/network/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Network Manager implementation for DBUS."""

import logging
from typing import Any

Expand Down
Loading

0 comments on commit f6faa18

Please sign in to comment.