mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Simplify invalidating the User cache (#115074)
This commit is contained in:
parent
f2fe2c4510
commit
32004973c8
@ -86,11 +86,7 @@ class User:
|
|||||||
def invalidate_cache(self) -> None:
|
def invalidate_cache(self) -> None:
|
||||||
"""Invalidate permission and is_admin cache."""
|
"""Invalidate permission and is_admin cache."""
|
||||||
for attr_to_invalidate in ("permissions", "is_admin"):
|
for attr_to_invalidate in ("permissions", "is_admin"):
|
||||||
# try is must more efficient than suppress
|
self.__dict__.pop(attr_to_invalidate, None)
|
||||||
try: # noqa: SIM105
|
|
||||||
delattr(self, attr_to_invalidate)
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@attr.s(slots=True)
|
@attr.s(slots=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user