From e494fee211abcea6950dd474fe7cb50a24808c18 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 1 Feb 2026 11:51:16 +0100 Subject: [PATCH] return empty shared_train_participants list if not shared_train --- docs/getting-started/changelog.rst | 1 + twitchio/models/eventsub_.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/getting-started/changelog.rst b/docs/getting-started/changelog.rst index 126a6f03..5835480d 100644 --- a/docs/getting-started/changelog.rst +++ b/docs/getting-started/changelog.rst @@ -37,6 +37,7 @@ Changelog - Fix some typing issues with adapters in :class:`~twitchio.Client`. - Fixed a bug causing conduit websockets to be treated as eventsub websockets and fail after a reconnect attempt. - Fixed incorrect documentation in :func:`~twitchio.PartialUser.fetch_moderators`. + - Fix :class:`~models.eventsub_.BaseHypeTrain` now returns empty list for shared_train_participants if not shared_train. 3.1.0 diff --git a/twitchio/models/eventsub_.py b/twitchio/models/eventsub_.py index f53f1fd4..e713174e 100644 --- a/twitchio/models/eventsub_.py +++ b/twitchio/models/eventsub_.py @@ -4957,11 +4957,15 @@ def __init__(self, payload: BaseHypeTrainEvent, *, http: HTTPClient) -> None: HypeTrainContribution(c, http=http) for c in payload["top_contributions"] ] self.started_at: datetime.datetime = parse_timestamp(payload["started_at"]) - self.shared_train_participants: list[PartialUser] = [ - PartialUser(u["broadcaster_user_id"], u["broadcaster_user_login"], u["broadcaster_user_name"], http=http) - for u in payload["shared_train_participants"] - ] self.shared_train: bool = bool(payload["is_shared_train"]) + self.shared_train_participants: list[PartialUser] = ( + [ + PartialUser(u["broadcaster_user_id"], u["broadcaster_user_login"], u["broadcaster_user_name"], http=http) + for u in payload["shared_train_participants"] + ] + if self.shared_train + else [] + ) self.type: Literal["treasure", "golden_kappa", "regular"] = payload["type"] def __repr__(self) -> str: