Simplify clearing _attr cached_property in entities (#113136)

This commit is contained in:
J. Nick Koston 2024-03-13 01:04:27 -10:00 committed by GitHub
parent 44538ed3c3
commit 6666f6a8a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -332,10 +332,7 @@ class CachedProperties(type):
Raises AttributeError if the __attr_ attribute does not exist
"""
# Invalidate the cache of the cached property
try: # noqa: SIM105 suppress is much slower
delattr(o, name)
except AttributeError:
pass
o.__dict__.pop(name, None)
# Delete the __attr_ attribute
delattr(o, private_attr_name)
@ -354,10 +351,8 @@ class CachedProperties(type):
if getattr(o, private_attr_name, _SENTINEL) == val:
return
setattr(o, private_attr_name, val)
try: # noqa: SIM105 suppress is much slower
delattr(o, name)
except AttributeError:
pass
# Invalidate the cache of the cached property
o.__dict__.pop(name, None)
return _setter