Skip to content

Commit 9abe3ce

Browse files
committed
run black
1 parent 1c2333a commit 9abe3ce

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

twitchio/ext/eventsub/websocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ async def pump(self) -> None:
209209
await self.connect()
210210
return
211211

212-
except TypeError as e:
212+
except TypeError as e:
213213
logger.warning(f"Received bad frame: {e.args[0]}")
214214

215-
if e.args[0] is None: # websocket was closed, reconnect
215+
if e.args[0] is None: # websocket was closed, reconnect
216216
logger.info("Known bad frame, restarting connection")
217217
await self.connect()
218218
return

twitchio/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ async def get_user_emotes(self, user_id: str, broadcaster_id: Optional[str], tok
709709
q: List = [("user_id", user_id)]
710710
if broadcaster_id:
711711
q.append(("broadcaster_id", broadcaster_id))
712-
712+
713713
return await self.request(Route("GET", "chat/emotes/user", query=q, token=token))
714714

715715
async def get_stream_key(self, token: str, broadcaster_id: str):

twitchio/models.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,15 +659,15 @@ class Emote:
659659
Represents an Emote.
660660
661661
.. note::
662-
662+
663663
It seems twitch is sometimes returning duplicate information from the emotes endpoint.
664664
To deduplicate your emotes, you can call ``set()`` on the list of emotes (or any other hashmap), which will remove the duplicates.
665665
666666
.. code-block:: python
667667
668668
my_list_of_emotes = await user.get_user_emotes(...)
669669
deduplicated_emotes = set(my_list_of_emotes)
670-
670+
671671
Attributes
672672
-----------
673673
id: :class:`str`
@@ -701,7 +701,18 @@ class Emote:
701701
Whether this emote is available in dark theme background mode.
702702
"""
703703

704-
__slots__ = "id", "set_id", "owner_id", "name", "type", "scales", "format_static", "format_animated", "theme_light", "theme_dark"
704+
__slots__ = (
705+
"id",
706+
"set_id",
707+
"owner_id",
708+
"name",
709+
"type",
710+
"scales",
711+
"format_static",
712+
"format_animated",
713+
"theme_light",
714+
"theme_dark",
715+
)
705716

706717
def __init__(self, data: dict) -> None:
707718
self.id: str = data["id"]
@@ -714,7 +725,7 @@ def __init__(self, data: dict) -> None:
714725
self.theme_light: bool = "light" in data["theme_mode"]
715726
self.format_static: bool = "static" in data["format"]
716727
self.format_animated: bool = "animated" in data["format"]
717-
728+
718729
def url_for(self, format: Literal["static", "animated"], theme: Literal["dark", "light"], scale: str) -> str:
719730
"""
720731
Returns a cdn url that can be used to download or serve the emote on a website.
@@ -729,26 +740,26 @@ def url_for(self, format: Literal["static", "animated"], theme: Literal["dark",
729740
scale: :class:`str`
730741
The scale of the emote. This should be formatted in this format: ``"1.0"``.
731742
The scales available for this emote can be checked via :attr:`~.scales`.
732-
743+
733744
Returns
734745
--------
735746
:class:`str`
736747
"""
737748
if scale not in self.scales:
738749
raise ValueError(f"scale for this emote must be one of {', '.join(self.scales)}, not {scale}")
739-
750+
740751
if (theme == "dark" and not self.theme_dark) or (theme == "light" and not self.theme_light):
741752
raise ValueError(f"theme {theme} is not an available value for this emote")
742753

743754
if (format == "static" and not self.format_static) or (format == "animated" and not self.format_animated):
744755
raise ValueError(f"format {format} is not an available value for this emote")
745-
756+
746757
return f"https://static-cdn.jtvnw.net/emoticons/v2/{self.id}/{format}/{theme}/{scale}"
747-
758+
748759
def __repr__(self) -> str:
749760
return f"<Emote id={self.id} name={self.name}>"
750761

751-
def __hash__(self) -> int: # this exists so we can do set(list of emotes) to get rid of duplicates
762+
def __hash__(self) -> int: # this exists so we can do set(list of emotes) to get rid of duplicates
752763
return hash(self.id)
753764

754765

twitchio/user.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,17 +639,17 @@ async def fetch_channel_emotes(self):
639639

640640
data = await self._http.get_channel_emotes(str(self.id))
641641
return [ChannelEmote(self._http, x) for x in data]
642-
642+
643643
async def fetch_user_emotes(self, token: str, broadcaster: Optional[PartialUser] = None) -> List[Emote]:
644644
"""|coro|
645-
645+
646646
Fetches emotes the user has access to. Optionally, you can filter by a broadcaster.
647647
648648
.. note::
649649
650650
As of writing, this endpoint seems extrememly unoptimized by twitch, and may (read: will) take a lot of API requests to load.
651651
See https://github.com/twitchdev/issues/issues/921 .
652-
652+
653653
Parameters
654654
-----------
655655
token: :class:`str`
@@ -663,6 +663,7 @@ async def fetch_user_emotes(self, token: str, broadcaster: Optional[PartialUser]
663663
List[:class:`~twitchio.Emote`]
664664
"""
665665
from .models import Emote
666+
666667
data = await self._http.get_user_emotes(str(self.id), broadcaster and str(broadcaster.id), token)
667668
return [Emote(d) for d in data]
668669

0 commit comments

Comments
 (0)