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 gathering ted5000 information."""
from contextlib import suppress
from datetime import timedelta
import logging
@ -73,10 +74,8 @@ class Ted5000Sensor(SensorEntity):
@property
def state(self):
"""Return the state of the resources."""
try:
with suppress(KeyError):
return self._gateway.data[self._mtu][self._unit]
except KeyError:
pass
def update(self):
"""Get the latest data from REST API."""