Skip to content

Commit b7412b0

Browse files
authored
Update Python to 3.13 (#5564)
* Bump Supervisor to Python 3.13 * Update ruff configuration to 0.9.1 Adjust pyproject.toml for ruff 0.9.1. Also make sure that latest version of ruff is used in pre-commit. * Set default configuration for pytest-asyncio * Run ruff check * Drop deprecated decorator no_type_check_decorator The upstream PR (python/cpython#106309) says this never got really implemented by type checkers. * Bump devcontainer to latest release
1 parent fff3bfd commit b7412b0

File tree

13 files changed

+31
-33
lines changed

13 files changed

+31
-33
lines changed

.devcontainer/devcontainer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Supervisor dev",
3-
"image": "ghcr.io/home-assistant/devcontainer:supervisor",
3+
"image": "ghcr.io/home-assistant/devcontainer:2-supervisor",
44
"containerEnv": {
55
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
66
},
@@ -44,5 +44,8 @@
4444
}
4545
}
4646
},
47-
"mounts": ["type=volume,target=/var/lib/docker"]
47+
"mounts": [
48+
"type=volume,target=/var/lib/docker",
49+
"type=volume,target=/mnt/supervisor"
50+
]
4851
}

.github/workflows/builder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333
- setup.py
3434

3535
env:
36-
DEFAULT_PYTHON: "3.12"
36+
DEFAULT_PYTHON: "3.13"
3737
BUILD_NAME: supervisor
3838
BUILD_TYPE: supervisor
3939

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request: ~
99

1010
env:
11-
DEFAULT_PYTHON: "3.12"
11+
DEFAULT_PYTHON: "3.13"
1212
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1313

1414
concurrency:

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.5.7
3+
rev: v0.9.1
44
hooks:
55
- id: ruff
66
args:
77
- --fix
88
- id: ruff-format
99
files: ^((supervisor|tests)/.+)?[^/]+\.py$
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.5.0
11+
rev: v5.0.0
1212
hooks:
1313
- id: check-executables-have-shebangs
1414
stages: [manual]

build.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
image: ghcr.io/home-assistant/{arch}-hassio-supervisor
22
build_from:
3-
aarch64: ghcr.io/home-assistant/aarch64-base-python:3.12-alpine3.20
4-
armhf: ghcr.io/home-assistant/armhf-base-python:3.12-alpine3.20
5-
armv7: ghcr.io/home-assistant/armv7-base-python:3.12-alpine3.20
6-
amd64: ghcr.io/home-assistant/amd64-base-python:3.12-alpine3.20
7-
i386: ghcr.io/home-assistant/i386-base-python:3.12-alpine3.20
3+
aarch64: ghcr.io/home-assistant/aarch64-base-python:3.13-alpine3.21
4+
armhf: ghcr.io/home-assistant/armhf-base-python:3.13-alpine3.21
5+
armv7: ghcr.io/home-assistant/armv7-base-python:3.13-alpine3.21
6+
amd64: ghcr.io/home-assistant/amd64-base-python:3.13-alpine3.21
7+
i386: ghcr.io/home-assistant/i386-base-python:3.13-alpine3.21
88
codenotary:
99
1010
base_image: [email protected]

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = [
1212
{ name = "The Home Assistant Authors", email = "[email protected]" },
1313
]
1414
keywords = ["docker", "home-assistant", "api"]
15-
requires-python = ">=3.12.0"
15+
requires-python = ">=3.13.0"
1616

1717
[project.urls]
1818
"Homepage" = "https://www.home-assistant.io/"
@@ -31,7 +31,7 @@ include-package-data = true
3131
include = ["supervisor*"]
3232

3333
[tool.pylint.MAIN]
34-
py-version = "3.12"
34+
py-version = "3.13"
3535
# Use a conservative default here; 2 should speed up most setups and not hurt
3636
# any too bad. Override on command line as appropriate.
3737
jobs = 2
@@ -147,7 +147,7 @@ disable = [
147147
# "pointless-statement", # B018, ruff catches new occurrences, needs more work
148148
"raise-missing-from", # TRY200
149149
# "redefined-builtin", # A001, ruff is way more stricter, needs work
150-
"try-except-raise", # TRY302
150+
"try-except-raise", # TRY203
151151
"unused-argument", # ARG001, we don't use it
152152
"unused-format-string-argument", #F507
153153
"unused-format-string-key", # F504
@@ -223,6 +223,7 @@ testpaths = ["tests"]
223223
norecursedirs = [".git"]
224224
log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(name)s:%(filename)s:%(lineno)s %(message)s"
225225
log_date_format = "%Y-%m-%d %H:%M:%S"
226+
asyncio_default_fixture_loop_scope = "function"
226227
asyncio_mode = "auto"
227228
filterwarnings = [
228229
"error",
@@ -289,7 +290,7 @@ lint.select = [
289290
"T20", # flake8-print
290291
"TID251", # Banned imports
291292
"TRY004", # Prefer TypeError exception for invalid type
292-
"TRY302", # Remove exception handler; error is immediately re-raised
293+
"TRY203", # Remove exception handler; error is immediately re-raised
293294
"UP", # pyupgrade
294295
"W", # pycodestyle
295296
]

requirements_tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ coverage==7.6.10
33
pre-commit==4.1.0
44
pylint==3.3.3
55
pytest-aiohttp==1.0.5
6-
pytest-asyncio==0.23.6
6+
pytest-asyncio==0.25.2
77
pytest-cov==6.0.0
88
pytest-timeout==2.3.1
99
pytest==8.3.4

supervisor/api/host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ async def advanced_logs_handler(
239239
# return 2 lines at minimum.
240240
lines = max(2, lines)
241241
# entries=cursor[[:num_skip]:num_entries]
242-
range_header = f"entries=:-{lines-1}:{'' if follow else lines}"
242+
range_header = f"entries=:-{lines - 1}:{'' if follow else lines}"
243243
elif RANGE in request.headers:
244244
range_header = request.headers.get(RANGE)
245245
else:
246246
range_header = (
247-
f"entries=:-{DEFAULT_LINES-1}:{'' if follow else DEFAULT_LINES}"
247+
f"entries=:-{DEFAULT_LINES - 1}:{'' if follow else DEFAULT_LINES}"
248248
)
249249

250250
async with self.sys_host.logs.journald_logs(

supervisor/utils/systemd_journal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def journal_verbose_formatter(entries: dict[str, str]) -> str:
6161

6262
async def journal_logs_reader(
6363
journal_logs: ClientResponse, log_formatter: LogFormatter = LogFormatter.PLAIN
64-
) -> AsyncGenerator[(str | None, str), None]:
64+
) -> AsyncGenerator[str | None, str]:
6565
"""Read logs from systemd journal line by line, formatted using the given formatter.
6666
6767
Returns a generator of (cursor, formatted_entry) tuples.

tests/api/test_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from supervisor.const import ATTR_ACCESS_TOKEN
1919

2020

21-
def id_generator() -> Generator[int, None, None]:
21+
def id_generator() -> Generator[int]:
2222
"""Generate IDs for WS messages."""
2323
i = 0
2424
while True:

0 commit comments

Comments
 (0)