Skip to content

Commit

Permalink
Make extra state attributes not optional
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek committed May 29, 2023
1 parent 0c5e899 commit d2f9e93
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions homeassistant/components/youtube/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class YouTubeMixin:

value_fn: Callable[[Any], StateType]
entity_picture_fn: Callable[[Any], str]
attributes_fn: Callable[[Any], dict[str, Any]] | None
attributes_fn: Callable[[Any], dict[str, Any]]


@dataclass
Expand All @@ -57,7 +57,7 @@ class YouTubeSensorEntityDescription(SensorEntityDescription, YouTubeMixin):
native_unit_of_measurement="subscribers",
value_fn=lambda channel: channel[ATTR_SUBSCRIBER_COUNT],
entity_picture_fn=lambda channel: channel[ATTR_ICON],
attributes_fn=None,
attributes_fn=lambda _: {},
),
]

Expand Down Expand Up @@ -92,8 +92,6 @@ def entity_picture(self) -> str:
return self.entity_description.entity_picture_fn(self._channel)

@property
def extra_state_attributes(self) -> dict[str, Any] | None:
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the extra state attributes."""
if self.entity_description.attributes_fn:
return self.entity_description.attributes_fn(self._channel)
return None
return self.entity_description.attributes_fn(self._channel)

0 comments on commit d2f9e93

Please sign in to comment.