Fix unhandled exception with missing IQVIA data (#125114)

This commit is contained in:
Aaron Bach 2024-09-03 06:21:52 -06:00 committed by Bram Kragten
parent a0bbcb0401
commit 393a0ac0df

View File

@ -244,8 +244,8 @@ class IndexSensor(IQVIAEntity, SensorEntity):
key = self.entity_description.key.split("_")[-1].title()
try:
[period] = [p for p in data["periods"] if p["Type"] == key] # type: ignore[index]
except TypeError:
period = next(p for p in data["periods"] if p["Type"] == key) # type: ignore[index]
except StopIteration:
return
data = cast(dict[str, Any], data)