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 GitHub
parent d12c6f89d2
commit c71cf272c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)