1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

update minimal python version to 3.10 (#8850)

This commit is contained in:
Thomas Rupprecht
2025-05-22 03:21:43 +02:00
committed by GitHub
parent 026f47bfb3
commit aeb4e63950
36 changed files with 148 additions and 166 deletions

View File

@@ -7,7 +7,6 @@ from pathlib import Path
import platform
import re
import tempfile
from typing import Union
from urllib.parse import urlparse
_LOGGER = logging.getLogger(__name__)
@@ -219,8 +218,8 @@ def sort_ip_addresses(address_list: list[str]) -> list[str]:
int,
int,
int,
Union[str, None],
Union[tuple[str, int], tuple[str, int, int, int]],
str | None,
tuple[str, int] | tuple[str, int, int, int],
]
] = []
for addr in address_list:
@@ -282,7 +281,7 @@ def read_file(path):
raise EsphomeError(f"Error reading file {path}: {err}") from err
def _write_file(path: Union[Path, str], text: Union[str, bytes]):
def _write_file(path: Path | str, text: str | bytes):
"""Atomically writes `text` to the given path.
Automatically creates all parent directories.
@@ -315,7 +314,7 @@ def _write_file(path: Union[Path, str], text: Union[str, bytes]):
_LOGGER.error("Write file cleanup failed: %s", err)
def write_file(path: Union[Path, str], text: str):
def write_file(path: Path | str, text: str):
try:
_write_file(path, text)
except OSError as err:
@@ -324,7 +323,7 @@ def write_file(path: Union[Path, str], text: str):
raise EsphomeError(f"Could not write file at {path}") from err
def write_file_if_changed(path: Union[Path, str], text: str) -> bool:
def write_file_if_changed(path: Path | str, text: str) -> bool:
"""Write text to the given path, but not if the contents match already.
Returns true if the file was changed.