Skip to content

Commit bc0b740

Browse files
committed
More Literal changes
1 parent 2a17329 commit bc0b740

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

twitchio/models/chat.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,17 @@ class ChannelEmote(Emote):
398398
The name of the emote.
399399
images: dict[str, str]
400400
Contains the image URLs for the emote. These image URLs will always provide a static (i.e., non-animated) emote image with a light background.
401-
tier: str
402-
This field contains the tier information only if type is set to ``subscriptions``, otherwise, it's an empty string.
401+
tier: typing.Literal["1000", "2000", "3000"] | None
402+
This field contains the tier information only if type is set to ``subscriptions``, otherwise it's `None`.
403403
set_id: str
404404
An ID that identifies the emote set that the emote belongs to.
405-
type: str
406-
The type of emote. The possible values are: ``bitstier``, ``follower``, ``subscriptions``.
405+
type: typing.Literal["bitstier", "follower", "subscriptions"]
406+
The type of emote. The possible values are:
407+
408+
- bitstier — A custom Bits tier emote.
409+
- follower — A custom follower emote.
410+
- subscriptions — A custom subscriber emote.
411+
407412
owner: PartialUser
408413
The :class:`~twitchio.PartialUser` who owns this emote.
409414
format: list[str]
@@ -419,9 +424,9 @@ class ChannelEmote(Emote):
419424
def __init__(self, data: ChannelEmotesResponseData, *, template: str, http: HTTPClient) -> None:
420425
super().__init__(data, template=template, http=http)
421426
self.images: ChannelEmotesResponseImages = data["images"]
422-
self.tier: str = data["tier"]
427+
self.tier: Literal["1000", "2000", "3000"] | None = data.get("tier")
423428
self.set_id: str = data["emote_set_id"]
424-
self.type: str = data["emote_type"]
429+
self.type: Literal["bitstier", "follower", "subscriptions"] = data["emote_type"]
425430

426431
def __repr__(self) -> str:
427432
return f"<ChannelEmote id={self.id} name={self.name} set_id={self.set_id}>"

twitchio/models/subscriptions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from __future__ import annotations
2626

27-
from typing import TYPE_CHECKING
27+
from typing import TYPE_CHECKING, Literal
2828

2929
from twitchio.types_.responses import (
3030
CheckUserSubscriptionResponseData,
@@ -53,7 +53,7 @@ class UserSubscription:
5353
The broadcaster being subscribed to.
5454
gift: bool
5555
A Boolean value that determines whether the subscription is a gift subscription. Is ``True`` if the subscription was gifted.
56-
tier: int
56+
tier: typing.Literal["1000", "2000", "3000"]
5757
The type of subscription. Possible values are:
5858
5959
- 1000: Tier 1
@@ -78,7 +78,7 @@ def __init__(
7878
data["broadcaster_id"], data["broadcaster_login"], data["broadcaster_name"], http=http
7979
)
8080
self.gift: bool = bool(data["is_gift"])
81-
self.tier: int = int(data["tier"])
81+
self.tier: Literal["1000", "2000", "3000"] = data["tier"]
8282
_gifter_id, _gifter_login, _gifter_display_name = (
8383
data.get("gifter_id"),
8484
data.get("gifter_login"),
@@ -96,7 +96,7 @@ def __repr__(self) -> str:
9696
@property
9797
def rounded_tier(self) -> int:
9898
"""Returns the tier as a single digit. e.g. Tier 1000 = 1."""
99-
return round(self.tier / 1000)
99+
return round(int(self.tier) / 1000)
100100

101101

102102
class BroadcasterSubscription(UserSubscription):
@@ -108,7 +108,7 @@ class BroadcasterSubscription(UserSubscription):
108108
The broadcaster being subscribed to.
109109
gift: bool
110110
A Boolean value that determines whether the subscription is a gift subscription. Is ``True`` if the subscription was gifted.
111-
tier: int
111+
tier: typing.Literal["1000", "2000", "3000"]
112112
The type of subscription. Possible values are:
113113
114114
- 1000: Tier 1

twitchio/types_/responses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ class ChannelEmotesResponseData(TypedDict):
476476
id: str
477477
name: str
478478
images: ChannelEmotesResponseImages
479-
tier: str
480-
emote_type: str
479+
tier: Literal["1000", "2000", "3000"]
480+
emote_type: Literal["bitstier", "follower", "subscriptions"]
481481
emote_set_id: str
482482
format: list[str]
483483
scale: list[str]

0 commit comments

Comments
 (0)