diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 9ac8b2ef6e6..8771fb41247 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -17,7 +17,7 @@ import voluptuous as vol import yarl from . import config as conf_util, config_entries, core, loader -from .components import http, persistent_notification +from .components import http from .const import ( REQUIRED_NEXT_PYTHON_HA_RELEASE, REQUIRED_NEXT_PYTHON_VER, @@ -268,16 +268,31 @@ async def async_from_config_dict( REQUIRED_NEXT_PYTHON_HA_RELEASE and sys.version_info[:3] < REQUIRED_NEXT_PYTHON_VER ): - msg = ( - "Support for the running Python version " - f"{'.'.join(str(x) for x in sys.version_info[:3])} is deprecated and will " - f"be removed in Home Assistant {REQUIRED_NEXT_PYTHON_HA_RELEASE}. " - "Please upgrade Python to " - f"{'.'.join(str(x) for x in REQUIRED_NEXT_PYTHON_VER[:2])}." + current_python_version = ".".join(str(x) for x in sys.version_info[:3]) + required_python_version = ".".join(str(x) for x in REQUIRED_NEXT_PYTHON_VER[:2]) + _LOGGER.warning( + ( + "Support for the running Python version %s is deprecated and " + "will be removed in Home Assistant %s; " + "Please upgrade Python to %s" + ), + current_python_version, + REQUIRED_NEXT_PYTHON_HA_RELEASE, + required_python_version, ) - _LOGGER.warning(msg) - persistent_notification.async_create( - hass, msg, "Python version", "python_version" + issue_registry.async_create_issue( + hass, + core.DOMAIN, + "python_version", + is_fixable=False, + severity=issue_registry.IssueSeverity.WARNING, + breaks_in_ha_version=REQUIRED_NEXT_PYTHON_HA_RELEASE, + translation_key="python_version", + translation_placeholders={ + "current_python_version": current_python_version, + "required_python_version": required_python_version, + "breaks_in_ha_version": REQUIRED_NEXT_PYTHON_HA_RELEASE, + }, ) return hass diff --git a/homeassistant/components/homeassistant/strings.json b/homeassistant/components/homeassistant/strings.json index 2db00081eaa..d7c5216111c 100644 --- a/homeassistant/components/homeassistant/strings.json +++ b/homeassistant/components/homeassistant/strings.json @@ -3,6 +3,10 @@ "historic_currency": { "title": "The configured currency is no longer in use", "description": "The currency {currency} is no longer in use, please reconfigure the currency configuration." + }, + "python_version": { + "title": "Support for Python {current_python_version} is being removed", + "description": "Support for running Home Assistant in the current used Python version {current_python_version} is deprecated and will be removed in Home Assistant {breaks_in_ha_version}. Please upgrade Python to {required_python_version} to prevent your Home Assistant instance from breaking." } }, "system_health": { diff --git a/homeassistant/components/homeassistant/translations/en.json b/homeassistant/components/homeassistant/translations/en.json index 8008aa813aa..b41e5753995 100644 --- a/homeassistant/components/homeassistant/translations/en.json +++ b/homeassistant/components/homeassistant/translations/en.json @@ -3,6 +3,10 @@ "historic_currency": { "description": "The currency {currency} is no longer in use, please reconfigure the currency configuration.", "title": "The configured currency is no longer in use" + }, + "python_version": { + "description": "Support for running Home Assistant in the current used Python version {current_python_version} is deprecated and will be removed in Home Assistant {breaks_in_ha_version}. Please upgrade Python to {required_python_version} to prevent your Home Assistant instance from breaking.", + "title": "Support for Python {current_python_version} is being removed" } }, "system_health": { diff --git a/homeassistant/const.py b/homeassistant/const.py index 6fe8f3730ff..4201c7f2de4 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -12,9 +12,9 @@ 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_NEXT_PYTHON_VER: Final[tuple[int, int, int]] = (3, 9, 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 = "" +REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = "2023.2" # Format for platform files PLATFORM_FORMAT: Final = "{platform}.{domain}" diff --git a/script/hassfest/requirements.py b/script/hassfest/requirements.py index b8fb22fb786..0e72e2eabd6 100644 --- a/script/hassfest/requirements.py +++ b/script/hassfest/requirements.py @@ -32,7 +32,8 @@ SUPPORTED_PYTHON_TUPLES = [ ] 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): - SUPPORTED_PYTHON_TUPLES.append((REQUIRED_PYTHON_VER[0], minor)) + 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 ]