Skip to content

Commit e494fee

Browse files
committed
return empty shared_train_participants list if not shared_train
1 parent 76e1cf2 commit e494fee

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/getting-started/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Changelog
3737
- Fix some typing issues with adapters in :class:`~twitchio.Client`.
3838
- Fixed a bug causing conduit websockets to be treated as eventsub websockets and fail after a reconnect attempt.
3939
- Fixed incorrect documentation in :func:`~twitchio.PartialUser.fetch_moderators`.
40+
- Fix :class:`~models.eventsub_.BaseHypeTrain` now returns empty list for shared_train_participants if not shared_train.
4041

4142

4243
3.1.0

twitchio/models/eventsub_.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4957,11 +4957,15 @@ def __init__(self, payload: BaseHypeTrainEvent, *, http: HTTPClient) -> None:
49574957
HypeTrainContribution(c, http=http) for c in payload["top_contributions"]
49584958
]
49594959
self.started_at: datetime.datetime = parse_timestamp(payload["started_at"])
4960-
self.shared_train_participants: list[PartialUser] = [
4961-
PartialUser(u["broadcaster_user_id"], u["broadcaster_user_login"], u["broadcaster_user_name"], http=http)
4962-
for u in payload["shared_train_participants"]
4963-
]
49644960
self.shared_train: bool = bool(payload["is_shared_train"])
4961+
self.shared_train_participants: list[PartialUser] = (
4962+
[
4963+
PartialUser(u["broadcaster_user_id"], u["broadcaster_user_login"], u["broadcaster_user_name"], http=http)
4964+
for u in payload["shared_train_participants"]
4965+
]
4966+
if self.shared_train
4967+
else []
4968+
)
49654969
self.type: Literal["treasure", "golden_kappa", "regular"] = payload["type"]
49664970

49674971
def __repr__(self) -> str:

0 commit comments

Comments
 (0)