diff --git a/homeassistant/components/http/static.py b/homeassistant/components/http/static.py index 022eb9387e5955fe3b0cb37c3e1cd2899262a0ce..99877eaf0be27e69f6e17e634b5f1961af48256f 100644 --- a/homeassistant/components/http/static.py +++ b/homeassistant/components/http/static.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Mapping from pathlib import Path -from typing import TYPE_CHECKING, Final +from typing import Final from aiohttp.hdrs import CACHE_CONTROL, CONTENT_TYPE from aiohttp.web import FileResponse, Request, StreamResponse @@ -17,12 +17,7 @@ CACHE_HEADER = f"public, max-age={CACHE_TIME}" CACHE_HEADERS: Mapping[str, str] = {CACHE_CONTROL: CACHE_HEADER} RESPONSE_CACHE: LRU[tuple[str, Path], tuple[Path, str]] = LRU(512) -if TYPE_CHECKING: - # mypy uses Python 3.12 syntax for type checking - # once it uses Python 3.13, this can be removed - _GUESSER = CONTENT_TYPES.guess_type -else: - _GUESSER = CONTENT_TYPES.guess_file_type +_GUESSER = CONTENT_TYPES.guess_file_type class CachingStaticResource(StaticResource): diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 3681e941eee8d4bbdc71f321f163e962c89fbfee..b465528946932d614c09e688ac76a1671dd8a848 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -1,8 +1,6 @@ """Helpers for config validation using voluptuous.""" -# PEP 563 seems to break typing.get_type_hints when used -# with PEP 695 syntax. Fixed in Python 3.13. -# from __future__ import annotations +from __future__ import annotations from collections.abc import Callable, Hashable, Mapping import contextlib @@ -354,7 +352,7 @@ def ensure_list[_T](value: _T | None) -> list[_T] | list[Any]: """Wrap value in list if it is not one.""" if value is None: return [] - return cast("list[_T]", value) if isinstance(value, list) else [value] + return cast(list[_T], value) if isinstance(value, list) else [value] def entity_id(value: Any) -> str: diff --git a/mypy.ini b/mypy.ini index 4eb6bdff80bf1bc825507aa91067ed47296817ee..6a9bb29c3604b4125f3d2c9a1cc601424309f31b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3,7 +3,7 @@ # To update, run python3 -m script.hassfest -p mypy_config [mypy] -python_version = 3.12 +python_version = 3.13 platform = linux plugins = pydantic.mypy, pydantic.v1.mypy show_error_codes = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index cd37dbd543dc0de0d8fac40e4160fc9447517a12..1d7f2b5ed88824a24e72d8d5f1da60035a9512f0 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -9,6 +9,8 @@ import os from pathlib import Path from typing import Final +from homeassistant.const import REQUIRED_PYTHON_VER + from .model import Config, Integration # Component modules which should set no_implicit_reexport = true. @@ -29,18 +31,7 @@ HEADER: Final = """ """.lstrip() GENERAL_SETTINGS: Final[dict[str, str]] = { - # We use @dataclass_transform in all our EntityDescriptions, causing - # `__replace__` to be already synthesized by mypy, causing **every** use of - # our entity descriptions to fail: - # - # error: Signature of "__replace__" incompatible with supertype "EntityDescription" - # - # Until this is fixed in mypy, we keep mypy locked on to Python 3.12 as we - # have done for the past few releases. - # - # Ref: https://github.com/python/mypy/issues/18216 - # "python_version": ".".join(str(x) for x in REQUIRED_PYTHON_VER[:2]), - "python_version": "3.12", + "python_version": ".".join(str(x) for x in REQUIRED_PYTHON_VER[:2]), "platform": "linux", "plugins": ", ".join( # noqa: FLY002 [