mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Simplify clearing _attr cached_property in entities (#113136)
This commit is contained in:
parent
44538ed3c3
commit
6666f6a8a5
@ -332,10 +332,7 @@ class CachedProperties(type):
|
|||||||
Raises AttributeError if the __attr_ attribute does not exist
|
Raises AttributeError if the __attr_ attribute does not exist
|
||||||
"""
|
"""
|
||||||
# Invalidate the cache of the cached property
|
# Invalidate the cache of the cached property
|
||||||
try: # noqa: SIM105 suppress is much slower
|
o.__dict__.pop(name, None)
|
||||||
delattr(o, name)
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
# Delete the __attr_ attribute
|
# Delete the __attr_ attribute
|
||||||
delattr(o, private_attr_name)
|
delattr(o, private_attr_name)
|
||||||
|
|
||||||
@ -354,10 +351,8 @@ class CachedProperties(type):
|
|||||||
if getattr(o, private_attr_name, _SENTINEL) == val:
|
if getattr(o, private_attr_name, _SENTINEL) == val:
|
||||||
return
|
return
|
||||||
setattr(o, private_attr_name, val)
|
setattr(o, private_attr_name, val)
|
||||||
try: # noqa: SIM105 suppress is much slower
|
# Invalidate the cache of the cached property
|
||||||
delattr(o, name)
|
o.__dict__.pop(name, None)
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return _setter
|
return _setter
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user