Skip to content

Commit

Permalink
Drop Python 3.12 support (home-assistant#135589)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Jan 14, 2025
1 parent fa96168 commit 60bdc13
Show file tree
Hide file tree
Showing 32 changed files with 62 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ env:
UV_CACHE_VERSION: 1
MYPY_CACHE_VERSION: 9
HA_SHORT_VERSION: "2025.2"
DEFAULT_PYTHON: "3.12"
ALL_PYTHON_VERSIONS: "['3.12', '3.13']"
DEFAULT_PYTHON: "3.13"
ALL_PYTHON_VERSIONS: "['3.13']"
# 10.3 is the oldest supported version
# - 10.3.32 is the version currently shipped with Synology (as of 17 Feb 2022)
# 10.6 is the current long-term-support
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "**strings.json"

env:
DEFAULT_PYTHON: "3.12"
DEFAULT_PYTHON: "3.13"

jobs:
upload:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- "script/gen_requirements_all.py"

env:
DEFAULT_PYTHON: "3.12"
DEFAULT_PYTHON: "3.13"

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name}}
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/auth/mfa_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import logging
import types
from typing import Any, Generic
from typing import Any, Generic, TypeVar

from typing_extensions import TypeVar
import voluptuous as vol
from voluptuous.humanize import humanize_error

Expand Down
3 changes: 1 addition & 2 deletions homeassistant/auth/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from collections.abc import Mapping
import logging
import types
from typing import Any, Generic
from typing import Any, Generic, TypeVar

from typing_extensions import TypeVar
import voluptuous as vol
from voluptuous.humanize import humanize_error

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/actiontec/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import logging
import telnetlib # pylint: disable=deprecated-module
from typing import Final

import telnetlib # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.device_tracker import (
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/assist_pipeline/websocket_api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""Assist pipeline Websocket API."""

import asyncio

# Suppressing disable=deprecated-module is needed for Python 3.11
import audioop # pylint: disable=deprecated-module
import base64
from collections.abc import AsyncGenerator, Callable
import contextlib
import logging
import math
from typing import Any, Final

# Suppressing disable=deprecated-module is needed for Python 3.11
import audioop # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components import conversation, stt, tts, websocket_api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any

from typing_extensions import TypeVar
from typing import TYPE_CHECKING, Any, TypeVar

from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers.update_coordinator import (
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/broadlink/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import suppress
from functools import partial
import logging
from typing import Generic
from typing import Generic, TypeVar

import broadlink as blk
from broadlink.exceptions import (
Expand All @@ -13,7 +13,6 @@
ConnectionClosedError,
NetworkTimeoutError,
)
from typing_extensions import TypeVar

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/broadlink/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from abc import ABC, abstractmethod
from datetime import datetime, timedelta
import logging
from typing import TYPE_CHECKING, Any, Generic
from typing import TYPE_CHECKING, Any, Generic, TypeVar

import broadlink as blk
from broadlink.exceptions import AuthorizationError, BroadlinkException
from typing_extensions import TypeVar

from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util import dt as dt_util
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/denon/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import logging
import telnetlib # pylint: disable=deprecated-module

import telnetlib # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.media_player import (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hddtemp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from datetime import timedelta
import logging
import socket
from telnetlib import Telnet # pylint: disable=deprecated-module
from typing import Any

from telnetlib import Telnet # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.sensor import (
Expand Down
15 changes: 6 additions & 9 deletions homeassistant/components/http/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

from collections.abc import Mapping
from pathlib import Path
import sys
from typing import Final
from typing import TYPE_CHECKING, Final

from aiohttp.hdrs import CACHE_CONTROL, CONTENT_TYPE
from aiohttp.web import FileResponse, Request, StreamResponse
Expand All @@ -18,14 +17,12 @@
CACHE_HEADERS: Mapping[str, str] = {CACHE_CONTROL: CACHE_HEADER}
RESPONSE_CACHE: LRU[tuple[str, Path], tuple[Path, str]] = LRU(512)

if sys.version_info >= (3, 13):
# guess_type is soft-deprecated in 3.13
# for paths and should only be used for
# URLs. guess_file_type should be used
# for paths instead.
_GUESSER = CONTENT_TYPES.guess_file_type
else:
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


class CachingStaticResource(StaticResource):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/pioneer/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import logging
import telnetlib # pylint: disable=deprecated-module
from typing import Final

import telnetlib # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.media_player import (
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/ring/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections.abc import Awaitable, Callable, Coroutine
from dataclasses import dataclass
from typing import Any, Concatenate, Generic, cast
from typing import Any, Concatenate, Generic, TypeVar, cast

from ring_doorbell import (
AuthenticationError,
Expand All @@ -11,7 +11,6 @@
RingGeneric,
RingTimeout,
)
from typing_extensions import TypeVar

from homeassistant.components.automation import automations_with_entity
from homeassistant.components.script import scripts_with_entity
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/telnet/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from datetime import timedelta
import logging
import telnetlib # pylint: disable=deprecated-module
from typing import Any

import telnetlib # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.switch import (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/thomson/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import logging
import re
import telnetlib # pylint: disable=deprecated-module

import telnetlib # pylint: disable=deprecated-module
import voluptuous as vol

from homeassistant.components.device_tracker import (
Expand Down
13 changes: 11 additions & 2 deletions homeassistant/components/weather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
from datetime import timedelta
from functools import partial
import logging
from typing import Any, Final, Generic, Literal, Required, TypedDict, cast, final
from typing import (
Any,
Final,
Generic,
Literal,
Required,
TypedDict,
TypeVar,
cast,
final,
)

from propcache import cached_property
from typing_extensions import TypeVar
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import logging
from random import randint
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Generic, Self, cast
from typing import TYPE_CHECKING, Any, Generic, Self, TypeVar, cast

from async_interrupt import interrupt
from propcache import cached_property
from typing_extensions import TypeVar
import voluptuous as vol

from . import data_entry_flow, loader
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,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, 12, 0)
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 13, 0)
REQUIRED_NEXT_PYTHON_VER: Final[tuple[int, int, int]] = (3, 13, 0)
# Truthy date string triggers showing related deprecation warning messages.
REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = "2025.2"
REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = ""

# Format for platform files
PLATFORM_FORMAT: Final = "{platform}.{domain}"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
NotRequired,
Self,
TypedDict,
TypeVar,
cast,
overload,
)

from propcache import cached_property, under_cached_property
from typing_extensions import TypeVar
import voluptuous as vol

from . import util
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/data_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
from enum import StrEnum
import logging
from types import MappingProxyType
from typing import Any, Generic, Required, TypedDict, cast
from typing import Any, Generic, Required, TypedDict, TypeVar, cast

from typing_extensions import TypeVar
import voluptuous as vol

from .core import HomeAssistant, callback
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/helpers/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from itertools import groupby
import logging
from operator import attrgetter
from typing import Any, Generic, TypedDict
from typing import Any, Generic, TypedDict, TypeVar

from typing_extensions import TypeVar
import voluptuous as vol
from voluptuous.humanize import humanize_error

Expand Down
3 changes: 1 addition & 2 deletions homeassistant/helpers/data_entry_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from __future__ import annotations

from http import HTTPStatus
from typing import Any, Generic
from typing import Any, Generic, TypeVar

from aiohttp import web
from typing_extensions import TypeVar
import voluptuous as vol
import voluptuous_serialize

Expand Down
4 changes: 1 addition & 3 deletions homeassistant/helpers/entity_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from datetime import timedelta
import logging
from types import ModuleType
from typing import Any, Generic

from typing_extensions import TypeVar
from typing import Any, Generic, TypeVar

from homeassistant import config as conf_util
from homeassistant.config_entries import ConfigEntry
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/helpers/update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
import logging
from random import randint
from time import monotonic
from typing import Any, Generic, Protocol
from typing import Any, Generic, Protocol, TypeVar
import urllib.error

import aiohttp
from propcache import cached_property
import requests
from typing_extensions import TypeVar

from homeassistant import config_entries
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/util/event_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any, Generic

from typing_extensions import TypeVar
from typing import Any, Generic, TypeVar

_DataT = TypeVar("_DataT", bound=Mapping[str, Any], default=Mapping[str, Any])

Expand Down
4 changes: 1 addition & 3 deletions homeassistant/util/event_type.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# ruff: noqa: PYI021 # Allow docstrings

from collections.abc import Mapping
from typing import Any, Generic

from typing_extensions import TypeVar
from typing import Any, Generic, TypeVar

__all__ = [
"EventType",
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Home Automation",
]
requires-python = ">=3.12.0"
requires-python = ">=3.13.0"
dependencies = [
"aiodns==3.2.0",
# Integrations may depend on hassio integration without listing it to
Expand Down Expand Up @@ -104,7 +103,7 @@ include-package-data = true
include = ["homeassistant*"]

[tool.pylint.MAIN]
py-version = "3.12"
py-version = "3.13"
# Use a conservative default here; 2 should speed up most setups and not hurt
# any too bad. Override on command line as appropriate.
jobs = 2
Expand Down
Loading

0 comments on commit 60bdc13

Please sign in to comment.