Reduce overhead to clear cache in button state (#113895)

Same optimization as #113136
This commit is contained in:
J. Nick Koston 2024-03-20 13:41:24 -10:00 committed by GitHub
parent 1e54595084
commit b311fe2a0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,10 +123,8 @@ class ButtonEntity(RestoreEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_
def __set_state(self, state: str | None) -> None:
"""Set the entity state."""
try: # noqa: SIM105 suppress is much slower
del self.state
except AttributeError:
pass
# Invalidate the cache of the cached property
self.__dict__.pop("state", None)
self.__last_pressed_isoformat = state
@final