Use contextlib.suppress where possible (#48189)

This commit is contained in:
Franck Nijhof 2021-03-23 14:36:43 +01:00 committed by GitHub
parent 9656f260a4
commit 6932cf9534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 238 additions and 398 deletions

View file

@ -1,4 +1,5 @@
"""Support for Wink sensors."""
from contextlib import suppress
import logging
import pywink
@ -87,9 +88,9 @@ class WinkSensorEntity(WinkDevice, SensorEntity):
def extra_state_attributes(self):
"""Return the state attributes."""
super_attrs = super().extra_state_attributes
try:
# Ignore error, this sensor isn't an eggminder
with suppress(AttributeError):
super_attrs["egg_times"] = self.wink.eggs()
except AttributeError:
# Ignore error, this sensor isn't an eggminder
pass
return super_attrs