diff --git a/homeassistant/components/cisco_webex_teams/notify.py b/homeassistant/components/cisco_webex_teams/notify.py index 60cb4a581c2796..30f56ac4712063 100644 --- a/homeassistant/components/cisco_webex_teams/notify.py +++ b/homeassistant/components/cisco_webex_teams/notify.py @@ -3,9 +3,9 @@ from __future__ import annotations import logging -import sys import voluptuous as vol +from webexteamssdk import ApiError, WebexTeamsAPI, exceptions from homeassistant.components.notify import ( ATTR_TITLE, @@ -14,14 +14,9 @@ ) from homeassistant.const import CONF_TOKEN from homeassistant.core import HomeAssistant -from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -if sys.version_info < (3, 12): - from webexteamssdk import ApiError, WebexTeamsAPI, exceptions - - _LOGGER = logging.getLogger(__name__) CONF_ROOM_ID = "room_id" @@ -37,11 +32,6 @@ def get_service( discovery_info: DiscoveryInfoType | None = None, ) -> CiscoWebexTeamsNotificationService | None: """Get the CiscoWebexTeams notification service.""" - if sys.version_info >= (3, 12): - raise HomeAssistantError( - "Cisco Webex Teams is not supported on Python 3.12. Please use Python 3.11." - ) - client = WebexTeamsAPI(access_token=config[CONF_TOKEN]) try: # Validate the token & room_id diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index ce32be40b30741..92499a05af48e4 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -11,9 +11,7 @@ from functools import partial import logging from math import ceil, floor, isfinite, log10 -from typing import TYPE_CHECKING, Any, Final, Self, cast, final - -from typing_extensions import override +from typing import TYPE_CHECKING, Any, Final, Self, cast, final, override from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( # noqa: F401 diff --git a/homeassistant/const.py b/homeassistant/const.py index 5c2908dc515d3f..6e657469b9a364 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -20,10 +20,10 @@ PATCH_VERSION: Final = "0.dev0" __short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__: Final = f"{__short_version__}.{PATCH_VERSION}" -REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 11, 0) +REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 12, 0) REQUIRED_NEXT_PYTHON_VER: Final[tuple[int, int, int]] = (3, 12, 0) # Truthy date string triggers showing related deprecation warning messages. -REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = "2024.4" +REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = "" # Format for platform files PLATFORM_FORMAT: Final = "{platform}.{domain}" diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index acf5d8e663966b..8c042242e0beb1 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -8,7 +8,6 @@ from contextlib import suppress import functools import logging -import sys import threading from typing import Any, ParamSpec, TypeVar, TypeVarTuple @@ -23,35 +22,20 @@ _P = ParamSpec("_P") _Ts = TypeVarTuple("_Ts") -if sys.version_info >= (3, 12, 0): - - def create_eager_task( - coro: Coroutine[Any, Any, _T], - *, - name: str | None = None, - loop: AbstractEventLoop | None = None, - ) -> Task[_T]: - """Create a task from a coroutine and schedule it to run immediately.""" - return Task( - coro, - loop=loop or get_running_loop(), - name=name, - eager_start=True, # type: ignore[call-arg] - ) -else: - - def create_eager_task( - coro: Coroutine[Any, Any, _T], - *, - name: str | None = None, - loop: AbstractEventLoop | None = None, - ) -> Task[_T]: - """Create a task from a coroutine and schedule it to run immediately.""" - return Task( - coro, - loop=loop or get_running_loop(), - name=name, - ) + +def create_eager_task( + coro: Coroutine[Any, Any, _T], + *, + name: str | None = None, + loop: AbstractEventLoop | None = None, +) -> Task[_T]: + """Create a task from a coroutine and schedule it to run immediately.""" + return Task( + coro, + loop=loop or get_running_loop(), + name=name, + eager_start=True, + ) def cancelling(task: Future[Any]) -> bool: diff --git a/homeassistant/util/frozen_dataclass_compat.py b/homeassistant/util/frozen_dataclass_compat.py index 68db3cd68322b3..fa86ce8ff87e44 100644 --- a/homeassistant/util/frozen_dataclass_compat.py +++ b/homeassistant/util/frozen_dataclass_compat.py @@ -8,9 +8,7 @@ import dataclasses import sys -from typing import Any - -from typing_extensions import dataclass_transform +from typing import Any, dataclass_transform def _class_fields(cls: type, kw_only: bool) -> list[tuple[str, Any, Any]]: diff --git a/mypy.ini b/mypy.ini index a8b146059fcb4b..81f6f553eb6260 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.11 +python_version = 3.12 plugins = pydantic.mypy show_error_codes = true follow_imports = silent diff --git a/pyproject.toml b/pyproject.toml index d6137b3d7ba1f7..965827f41eabc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,10 +18,10 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Home Automation", ] -requires-python = ">=3.11.0" +requires-python = ">=3.12.0" dependencies = [ "aiohttp==3.9.3", "aiohttp_cors==0.7.0", @@ -90,7 +90,7 @@ include-package-data = true include = ["homeassistant*"] [tool.pylint.MAIN] -py-version = "3.11" +py-version = "3.12" ignore = [ "tests", ] @@ -705,6 +705,8 @@ ignore = [ "UP007", # keep type annotation style as is # Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923 "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` + # Ignored due to incompatible with mypy: https://github.com/python/mypy/issues/15238 + "UP040", # Checks for use of TypeAlias annotation for declaring type aliases. # May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191",