Improve type hint in brottsplatskartan sensor entity (#77019)

This commit is contained in:
epenet 2022-08-19 12:09:58 +02:00 committed by GitHub
parent 63dcd8ec08
commit 039c071a80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,7 +87,7 @@ class BrottsplatskartanSensor(SensorEntity):
_attr_attribution = brottsplatskartan.ATTRIBUTION
def __init__(self, bpk, name):
def __init__(self, bpk: brottsplatskartan.BrottsplatsKartan, name: str) -> None:
"""Initialize the Brottsplatskartan sensor."""
self._brottsplatskartan = bpk
self._attr_name = name
@ -103,8 +103,8 @@ class BrottsplatskartanSensor(SensorEntity):
return
for incident in incidents:
incident_type = incident.get("title_type")
incident_counts[incident_type] += 1
if (incident_type := incident.get("title_type")) is not None:
incident_counts[incident_type] += 1
self._attr_extra_state_attributes = incident_counts
self._attr_native_value = len(incidents)