Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove as_compressed_state cache #93169

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,6 @@ class State:
"domain",
"object_id",
"_as_dict",
"_as_compressed_state",
"_as_dict_json",
"_as_compressed_state_json",
)
Expand Down Expand Up @@ -1262,7 +1261,6 @@ def __init__(
self.context = context or Context()
self.domain, self.object_id = split_entity_id(self.entity_id)
self._as_dict: ReadOnlyDict[str, Collection[Any]] | None = None
self._as_compressed_state: dict[str, Any] | None = None
self._as_dict_json: str | None = None
self._as_compressed_state_json: str | None = None

Expand Down Expand Up @@ -1312,8 +1310,6 @@ def as_compressed_state(self) -> dict[str, Any]:

Sends c (context) as a string if it only contains an id.
"""
if self._as_compressed_state:
return self._as_compressed_state
state_context = self.context
if state_context.parent_id is None and state_context.user_id is None:
context: dict[str, Any] | str = state_context.id
Expand All @@ -1329,7 +1325,6 @@ def as_compressed_state(self) -> dict[str, Any]:
compressed_state[COMPRESSED_STATE_LAST_UPDATED] = dt_util.utc_to_timestamp(
self.last_updated
)
self._as_compressed_state = compressed_state
return compressed_state

def as_compressed_state_json(self) -> str:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ def test_state_as_compressed_state() -> None:
assert as_compressed_state == expected
# 2nd time to verify cache
assert state.as_compressed_state() == expected
assert state.as_compressed_state() is as_compressed_state


def test_state_as_compressed_state_unique_last_updated() -> None:
Expand All @@ -538,7 +537,6 @@ def test_state_as_compressed_state_unique_last_updated() -> None:
assert as_compressed_state == expected
# 2nd time to verify cache
assert state.as_compressed_state() == expected
assert state.as_compressed_state() is as_compressed_state


def test_state_as_compressed_state_json() -> None:
Expand Down