mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Update Python version for mypy to 3.13 (#135636)
This commit is contained in:
@ -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):
|
||||
|
@ -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:
|
||||
|
2
mypy.ini
generated
2
mypy.ini
generated
@ -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
|
||||
|
@ -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
|
||||
[
|
||||
|
Reference in New Issue
Block a user