From 920d281d45776cc3a65daa3b2b386cc299dd30f4 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Fri, 9 May 2025 14:40:23 +0200 Subject: [PATCH] Remove deprecated core set_time_zone function (#144559) --- homeassistant/core_config.py | 21 --------------------- tests/test_core_config.py | 13 ------------- 2 files changed, 34 deletions(-) diff --git a/homeassistant/core_config.py b/homeassistant/core_config.py index 9cd232097a7..ccae24a907b 100644 --- a/homeassistant/core_config.py +++ b/homeassistant/core_config.py @@ -60,7 +60,6 @@ from .core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from .generated.currencies import HISTORIC_CURRENCIES from .helpers import config_validation as cv, issue_registry as ir from .helpers.entity_values import EntityValues -from .helpers.frame import ReportBehavior, report_usage from .helpers.storage import Store from .helpers.typing import UNDEFINED, UndefinedType from .util import dt as dt_util, location @@ -712,26 +711,6 @@ class Config: else: raise ValueError(f"Received invalid time zone {time_zone_str}") - def set_time_zone(self, time_zone_str: str) -> None: - """Set the time zone. - - This is a legacy method that should not be used in new code. - Use async_set_time_zone instead. - - It will be removed in Home Assistant 2025.6. - """ - report_usage( - "sets the time zone using set_time_zone instead of async_set_time_zone", - core_integration_behavior=ReportBehavior.ERROR, - custom_integration_behavior=ReportBehavior.ERROR, - breaks_in_ha_version="2025.6", - ) - if time_zone := dt_util.get_time_zone(time_zone_str): - self.time_zone = time_zone_str - dt_util.set_default_time_zone(time_zone) - else: - raise ValueError(f"Received invalid time zone {time_zone_str}") - async def _async_update( self, *, diff --git a/tests/test_core_config.py b/tests/test_core_config.py index 2723c8e7196..7fbd10db206 100644 --- a/tests/test_core_config.py +++ b/tests/test_core_config.py @@ -5,7 +5,6 @@ from collections import OrderedDict import copy import os from pathlib import Path -import re from tempfile import TemporaryDirectory from typing import Any from unittest.mock import Mock, PropertyMock, patch @@ -1072,18 +1071,6 @@ async def test_debug_mode_defaults_to_off(hass: HomeAssistant) -> None: assert not hass.config.debug -async def test_set_time_zone_deprecated(hass: HomeAssistant) -> None: - """Test set_time_zone is deprecated.""" - with pytest.raises( - RuntimeError, - match=re.escape( - "Detected code that sets the time zone using set_time_zone instead of " - "async_set_time_zone. Please report this issue" - ), - ): - await hass.config.set_time_zone("America/New_York") - - async def test_core_config_schema_imperial_unit( hass: HomeAssistant, issue_registry: ir.IssueRegistry ) -> None: