Use contextlib.suppress where possible (#48189)
This commit is contained in:
parent
9656f260a4
commit
6932cf9534
86 changed files with 238 additions and 398 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue