diff --git a/homeassistant/helpers/restore_state.py b/homeassistant/helpers/restore_state.py index a2b4b3a9b9a..fd1f84a85ff 100644 --- a/homeassistant/helpers/restore_state.py +++ b/homeassistant/helpers/restore_state.py @@ -17,7 +17,6 @@ from homeassistant.util.json import json_loads from . import start from .entity import Entity from .event import async_track_time_interval -from .frame import report from .json import JSONEncoder from .singleton import singleton from .storage import Store @@ -116,21 +115,6 @@ class RestoreStateData: """Dump states now.""" await async_get(hass).async_dump_states() - @classmethod - async def async_get_instance(cls, hass: HomeAssistant) -> RestoreStateData: - """Return the instance of this class.""" - # Nothing should actually be calling this anymore, but we'll keep it - # around for a while to avoid breaking custom components. - # - # In fact they should not be accessing this at all. - report( - "restore_state.RestoreStateData.async_get_instance is deprecated, " - "and not intended to be called by custom components; Please" - "refactor your code to use RestoreEntity instead;" - " restore_state.async_get(hass) can be used in the meantime", - ) - return async_get(hass) - def __init__(self, hass: HomeAssistant) -> None: """Initialize the restore state data class.""" self.hass: HomeAssistant = hass diff --git a/tests/helpers/test_restore_state.py b/tests/helpers/test_restore_state.py index 865ee5efaf7..7adb3dd5b5e 100644 --- a/tests/helpers/test_restore_state.py +++ b/tests/helpers/test_restore_state.py @@ -6,8 +6,6 @@ import logging from typing import Any from unittest.mock import Mock, patch -import pytest - from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP from homeassistant.core import CoreState, HomeAssistant, State from homeassistant.exceptions import HomeAssistantError @@ -94,20 +92,6 @@ async def test_caching_data(hass: HomeAssistant) -> None: assert mock_write_data.called -async def test_async_get_instance_backwards_compatibility(hass: HomeAssistant) -> None: - """Test async_get_instance backwards compatibility.""" - await async_load(hass) - data = async_get(hass) - # When called from core it should raise - with pytest.raises(RuntimeError): - await RestoreStateData.async_get_instance(hass) - - # When called from a component it should not raise - # but it should report - with patch("homeassistant.helpers.restore_state.report"): - assert data is await RestoreStateData.async_get_instance(hass) - - async def test_periodic_write(hass: HomeAssistant) -> None: """Test that we write periodiclly but not after stop.""" data = async_get(hass)