Skip to content

Commit

Permalink
Drop Python 3.11 support (home-assistant#114220)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Mar 26, 2024
1 parent 31f5576 commit 2388e2d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 53 deletions.
12 changes: 1 addition & 11 deletions homeassistant/components/cisco_webex_teams/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
44 changes: 14 additions & 30 deletions homeassistant/util/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from contextlib import suppress
import functools
import logging
import sys
import threading
from typing import Any, ParamSpec, TypeVar, TypeVarTuple

Expand All @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/util/frozen_dataclass_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -90,7 +90,7 @@ include-package-data = true
include = ["homeassistant*"]

[tool.pylint.MAIN]
py-version = "3.11"
py-version = "3.12"
ignore = [
"tests",
]
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2388e2d

Please sign in to comment.