Remove deprecated core set_time_zone function (#144559)

This commit is contained in:
Robert Resch 2025-05-09 14:40:23 +02:00 committed by GitHub
parent d2bdc85a7b
commit 920d281d45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 34 deletions

View File

@ -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,
*,

View File

@ -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: