Skip to content

Commit

Permalink
Update method docstrings with coro / aiter
Browse files Browse the repository at this point in the history
  • Loading branch information
chillymosh committed Feb 9, 2025
1 parent 1014563 commit 25cd824
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 29 deletions.
12 changes: 9 additions & 3 deletions twitchio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ async def setup_hook(self) -> None:
...

async def login(self, *, token: str | None = None, load_tokens: bool = True, save_tokens: bool = True) -> None:
"""Method to login the client and generate or store an app token.
"""|coro|
Method to login the client and generate or store an app token.
This method is called automatically when using :meth:`~.start`.
You should **NOT** call this method if you are using :meth:`~.start`.
Expand Down Expand Up @@ -461,7 +463,9 @@ async def run() -> None:
pass

async def close(self, **options: Any) -> None:
r"""Method which closes the :class:`~Client` gracefully.
r"""|coro|
Method which closes the :class:`~Client` gracefully.
This method is called for you automatically when using :meth:`~.run` or when using the client with the
async context-manager, E.g: `async with client:`
Expand Down Expand Up @@ -536,7 +540,9 @@ async def wait_until_ready(self) -> None:
await self._ready_event.wait()

async def wait_for(self, event: str, *, timeout: float | None = None, predicate: WaitPredicateT | None = None) -> Any:
"""Method which waits for any known dispatched event and returns the payload associated with the event.
"""|coro|
Method which waits for any known dispatched event and returns the payload associated with the event.
This method can be used with a predicate check to determine whether the `wait_for` should stop listening and return
the event payload.
Expand Down
22 changes: 16 additions & 6 deletions twitchio/models/channel_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ def get_image(self, size: Literal["1x", "2x", "4x"] = "2x", use_default: bool =
return Asset(url, http=self._http)

async def delete(self) -> None:
"""Delete the custom reward.
"""|coro|
The app used to create the reward is the only app that may delete it.
Delete the custom reward.
The app / client ID used to create the reward is the only app that may delete it.
If the reward's redemption status is UNFULFILLED at the time the reward is deleted, its redemption status is marked as FULFILLED.
.. note::
Expand All @@ -248,7 +250,9 @@ async def update(
paused: bool | None = None,
skip_queue: bool | None = None,
) -> CustomReward:
"""Update the custom reward.
"""|coro|
Update the custom reward.
.. important::
The app / client ID used to create the reward is the only app that may update the reward.
Expand Down Expand Up @@ -336,7 +340,9 @@ def fetch_redemptions(
sort: Literal["OLDEST", "NEWEST"] = "OLDEST",
first: int = 20,
) -> HTTPAsyncIterator[CustomRewardRedemption]:
"""Fetch redemptions from the CustomReward.
"""|aiter|
Fetch redemptions from the CustomReward.
Canceled and fulfilled redemptions are returned for only a few days after they're canceled or fulfilled.
Expand Down Expand Up @@ -419,7 +425,9 @@ def __repr__(self) -> str:
return f"<CustomRewardRedemption id={self.id} status={self.status} redeemed_at={self.redeemed_at}>"

async def fulfill(self) -> CustomRewardRedemption:
"""Updates a redemption's status to FULFILLED.
"""|coro|
Updates a redemption's status to FULFILLED.
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Expand All @@ -439,7 +447,9 @@ async def fulfill(self) -> CustomRewardRedemption:
return CustomRewardRedemption(data["data"][0], parent_reward=self.reward, http=self._http)

async def refund(self) -> CustomRewardRedemption:
"""Updates a redemption's status to CANCELED.
"""|coro|
Updates a redemption's status to CANCELED.
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def __repr__(self) -> str:
return f"<ChannelInfo user={self.user} game_id={self.game_id} game_name={self.game_name} title={self.title} language={self.language} delay={self.delay}>"

async def fetch_game(self) -> Game:
"""Fetches the :class:~twitchio.Game` associated with this ChannelInfo.
"""|coro|
Fetches the :class:~twitchio.Game` associated with this ChannelInfo.
Returns
-------
Expand Down
8 changes: 6 additions & 2 deletions twitchio/models/clips.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def __str__(self) -> str:
return self.id

async def fetch_game(self) -> Game:
"""Fetches the :class:`~twitchio.Game` associated with this Clip.
"""|coro|
Fetches the :class:`~twitchio.Game` associated with this Clip.
Returns
-------
Expand All @@ -137,7 +139,9 @@ async def fetch_game(self) -> Game:
return Game(payload["data"][0], http=self._http)

async def fetch_video(self) -> Video | None:
"""Fetches the :class:`~twitchio.Video` associated with this clip, if it can be found.
"""|coro|
Fetches the :class:`~twitchio.Video` associated with this clip, if it can be found.
Returns
-------
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/entitlements.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def __str__(self) -> str:
return self.id

async def fetch_game(self) -> Game:
"""Fetches the :class:`~twitchio.Game` associated with this drop entitlement.
"""|coro|
Fetches the :class:`~twitchio.Game` associated with this drop entitlement.
Returns
-------
Expand Down
13 changes: 9 additions & 4 deletions twitchio/models/eventsub_.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ def __repr__(self) -> str:
return f"<ChatMessageEmote set_id={self.set_id} id={self.id} owner={self.owner} format={self.format}>"

async def fetch_emote_set(self, *, token_for: str | PartialUser | None = None) -> EmoteSet:
"""
"""|coro|
Fetches emotes for this emote set.
Parameters
Expand Down Expand Up @@ -3431,7 +3432,8 @@ def __repr__(self) -> str:
return f"<ChannelPointsRedemptionAdd broadcaster={self.broadcaster} user={self.user} status={self.status} redeemed_at={self.redeemed_at}>"

async def fulfill(self, *, token_for: str | PartialUser) -> CustomRewardRedemption:
"""
"""|coro|
Updates the redemption's status to FULFILLED.
.. note::
Expand Down Expand Up @@ -3459,7 +3461,8 @@ async def fulfill(self, *, token_for: str | PartialUser) -> CustomRewardRedempti
return CustomRewardRedemption(data["data"][0], parent_reward=reward, http=self._http)

async def refund(self, *, token_for: str | PartialUser) -> CustomRewardRedemption:
"""
"""|coro|
Updates the redemption's status to CANCELED.
.. note::
Expand Down Expand Up @@ -5171,7 +5174,9 @@ def __repr__(self) -> str:
return f"<EventsubSubscription id={self.id} status={self.status} transport={self.transport} type={self.type} version={self.version} condition={self.condition} created_at={self.created_at} cost={self.cost}>"

async def delete(self, *, token_for: str | None = None) -> None:
"""Delete the eventsub subscription.
"""|coro|
Delete the eventsub subscription.
Parameters
----------
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/polls.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def __repr__(self) -> str:
return f"<Poll id={self.id} title={self.title} status={self.status} started_at={self.started_at}>"

async def end_poll(self, *, status: Literal["ARCHIVED", "TERMINATED"]) -> Poll:
"""End an active poll.
"""|coro|
End an active poll.
.. note::
Requires user access token that includes the `channel:manage:polls` scope.
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ async def end_prediction(
status: Literal["RESOLVED", "CANCELED", "LOCKED"],
winning_outcome_id: str | None = None,
) -> Prediction:
"""End an active prediction.
"""|coro|
End an active prediction.
.. note::
Requires user access token that includes the `channel:manage:predictions` scope.
Expand Down
11 changes: 7 additions & 4 deletions twitchio/models/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ def __repr__(self) -> str:
async def update_segment(
self,
*,
token_for: str | PartialUser,
start_time: datetime.datetime | None = None,
duration: int | None = None,
category_id: str | None = None,
title: str | None = None,
canceled: bool | None = None,
timezone: str | None = None,
) -> Schedule:
"""Updates a scheduled broadcast segment.
"""|coro|
Updates a scheduled broadcast segment.
.. note::
Requires a user access token that includes the ``channel:manage:schedule`` scope.
Expand Down Expand Up @@ -187,8 +188,10 @@ async def update_segment(

return Schedule(data["data"], http=self._http)

async def delete(self, *, token_for: str | PartialUser) -> None:
"""Removes a broadcast segment from the broadcaster's streaming schedule.
async def delete(self) -> None:
"""|coro|
Removes a broadcast segment from the broadcaster's streaming schedule.
For recurring segments, removing a segment removes all segments in the recurring schedule.
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def __repr__(self) -> str:
return f"<SearchChannel broadcaster={self.broadcaster} title={self.title} live={self.live} game_id={self.game_id}>"

async def fetch_game(self) -> Game:
"""Fetches the :class:`~twitchio.Game` associated with this channel.
"""|coro|
Fetches the :class:`~twitchio.Game` associated with this channel.
The :class:`~twitchio.Game` returned is current from the time the :class:`~twitchio.SearchChannel`
instance was created.
Expand Down
4 changes: 3 additions & 1 deletion twitchio/models/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def __repr__(self) -> str:
return f"<Stream id={self.id} user={self.user} title={self.title} started_at={self.started_at}>"

async def fetch_game(self) -> Game | None:
"""Fetches the :class:`~twitchio.Game` associated with this stream.
"""|coro|
Fetches the :class:`~twitchio.Game` associated with this stream.
The :class:`~twitchio.Game` returned is current from the time the :class:`~twitchio.Stream`
instance was created.
Expand Down
5 changes: 1 addition & 4 deletions twitchio/models/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ def __str__(self) -> str:
return self.name

def __eq__(self, __value: object) -> bool:
if not isinstance(__value, Team):
return NotImplemented

return __value.id == self.id
return __value.id == self.id if isinstance(__value, Team) else NotImplemented


class ChannelTeam:
Expand Down

0 comments on commit 25cd824

Please sign in to comment.