Skip to content

Commit

Permalink
Drop Python 3.9 support (home-assistant#85456)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Jan 22, 2023
1 parent 7661b22 commit 5102d1a
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
BUILD_TYPE: core
DEFAULT_PYTHON: 3.9
DEFAULT_PYTHON: "3.10"

jobs:
init:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ env:
CACHE_VERSION: 3
PIP_CACHE_VERSION: 3
HA_SHORT_VERSION: 2023.2
DEFAULT_PYTHON: 3.9
ALL_PYTHON_VERSIONS: "['3.9', '3.10']"
DEFAULT_PYTHON: "3.10"
ALL_PYTHON_VERSIONS: "['3.10']"
PRE_COMMIT_CACHE: ~/.cache/pre-commit
PIP_CACHE: /tmp/pip-cache
SQLALCHEMY_WARN_20: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/translations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- "**strings.json"

env:
DEFAULT_PYTHON: 3.9
DEFAULT_PYTHON: "3.10"

jobs:
upload:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.9
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lirc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, hass):
def run(self):
"""Run the loop of the LIRC interface thread."""
_LOGGER.debug("LIRC interface thread started")
while not self.stopped.isSet():
while not self.stopped.is_set():
try:
code = lirc.nextcode() # list; empty if no buttons pressed
except lirc.NextCodeError:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/radiotherm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ async def _async_call_or_raise_not_ready(
except RadiothermTstatError as ex:
msg = f"{host} was busy (invalid value returned): {ex}"
raise ConfigEntryNotReady(msg) from ex
except (OSError, URLError) as ex:
msg = f"{host} connection error: {ex}"
raise ConfigEntryNotReady(msg) from ex
except timeout as ex:
msg = f"{host} timed out waiting for a response: {ex}"
raise ConfigEntryNotReady(msg) from ex
except (OSError, URLError) as ex:
msg = f"{host} connection error: {ex}"
raise ConfigEntryNotReady(msg) from ex


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/radiotherm/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async def _async_update_data(self) -> RadioThermUpdate:
except RadiothermTstatError as ex:
msg = f"{self._description} was busy (invalid value returned): {ex}"
raise UpdateFailed(msg) from ex
except (OSError, URLError) as ex:
msg = f"{self._description} connection error: {ex}"
raise UpdateFailed(msg) from ex
except timeout as ex:
msg = f"{self._description}) timed out waiting for a response: {ex}"
raise UpdateFailed(msg) from ex
except (OSError, URLError) as ex:
msg = f"{self._description} connection error: {ex}"
raise UpdateFailed(msg) from ex
2 changes: 2 additions & 0 deletions homeassistant/components/websocket_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class WebSocketAdapter(logging.LoggerAdapter):

def process(self, msg: str, kwargs: Any) -> tuple[str, Any]:
"""Add connid to websocket log messages."""
if not self.extra or "connid" not in self.extra:
return msg, kwargs
return f'[{self.extra["connid"]}] {msg}', kwargs


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

# Format for platform files
PLATFORM_FORMAT: Final = "{platform}.{domain}"
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.9
python_version = 3.10
show_error_codes = true
follow_imports = silent
ignore_missing_imports = true
Expand Down
3 changes: 1 addition & 2 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.9",
"Programming Language :: Python :: 3.10",
"Topic :: Home Automation",
]
requires-python = ">=3.9.0"
requires-python = ">=3.10.0"
dependencies = [
"aiohttp==3.8.1",
"astral==2.2",
Expand Down
1 change: 0 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pytest-xdist==2.5.0
pytest==7.2.1
requests_mock==1.10.0
respx==0.20.1
stdlib-list==0.7.0
tomli==2.0.1;python_version<"3.11"
tqdm==4.64.0
types-atomicwrites==1.4.1
Expand Down
26 changes: 6 additions & 20 deletions script/hassfest/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
from typing import Any

from awesomeversion import AwesomeVersion, AwesomeVersionStrategy
from stdlib_list import stdlib_list
from tqdm import tqdm

from homeassistant.const import REQUIRED_NEXT_PYTHON_VER, REQUIRED_PYTHON_VER
import homeassistant.util.package as pkg_util
from script.gen_requirements_all import COMMENT_REQUIREMENTS, normalize_package_name

Expand All @@ -28,17 +26,6 @@
)
PIP_REGEX = re.compile(r"^(--.+\s)?([-_\.\w\d]+.*(?:==|>=|<=|~=|!=|<|>|===)?.*$)")
PIP_VERSION_RANGE_SEPARATOR = re.compile(r"^(==|>=|<=|~=|!=|<|>|===)?(.*)$")
SUPPORTED_PYTHON_TUPLES = [
REQUIRED_PYTHON_VER[:2],
]
if REQUIRED_PYTHON_VER[0] == REQUIRED_NEXT_PYTHON_VER[0]:
for minor in range(REQUIRED_PYTHON_VER[1] + 1, REQUIRED_NEXT_PYTHON_VER[1] + 1):
if minor < 10: # stdlib list does not support 3.10+
SUPPORTED_PYTHON_TUPLES.append((REQUIRED_PYTHON_VER[0], minor))
SUPPORTED_PYTHON_VERSIONS = [
".".join(map(str, version_tuple)) for version_tuple in SUPPORTED_PYTHON_TUPLES
]
STD_LIBS = {version: set(stdlib_list(version)) for version in SUPPORTED_PYTHON_VERSIONS}

IGNORE_VIOLATIONS = {
# Still has standard library requirements.
Expand Down Expand Up @@ -161,13 +148,12 @@ def validate_requirements(integration: Integration) -> None:
return

# Check for requirements incompatible with standard library.
for version, std_libs in STD_LIBS.items():
for req in all_integration_requirements:
if req in std_libs:
integration.add_error(
"requirements",
f"Package {req} is not compatible with Python {version} standard library",
)
for req in all_integration_requirements:
if req in sys.stlib_module_names:
integration.add_error(
"requirements",
f"Package {req} is not compatible with the Python standard library",
)


@cache
Expand Down

0 comments on commit 5102d1a

Please sign in to comment.