Drop Python 3.11 support (#114220)

This commit is contained in:
Franck Nijhof 2024-03-26 12:51:14 +01:00 committed by GitHub
parent 31f5576b6e
commit 2388e2dda9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 52 deletions

View File

@ -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.components.notify import (
)
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

View File

@ -11,9 +11,7 @@ from decimal import Decimal, InvalidOperation as DecimalInvalidOperation
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

View File

@ -20,10 +20,10 @@ MINOR_VERSION: Final = 4
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}"

View File

@ -8,7 +8,6 @@ import concurrent.futures
from contextlib import suppress
import functools
import logging
import sys
import threading
from typing import Any, ParamSpec, TypeVar, TypeVarTuple
@ -23,35 +22,20 @@ _R = TypeVar("_R")
_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:

View File

@ -8,9 +8,7 @@ from __future__ import annotations
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]]:

View File

@ -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

View File

@ -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",