Skip to content

Commit e59a4f3

Browse files
committed
add docs to partialuser and user
1 parent 92dc142 commit e59a4f3

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

docs/changelog.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Master
44
======
55
- TwitchIO
66
- Additions
7-
- Added following new PartialUser methods:
7+
- Add attribute docs to :class:`~twitchio.PartialUser` and :class:`~twitchio.User`
8+
- Added following new :class:`~twitchio.PartialUser` methods:
89
- :func:`twitchio.PartialUser.create_custom_reward`
910
- :func:`twitchio.PartialUser.chat_announcement`
1011
- :func:`twitchio.PartialUser.delete_chat_messages`
@@ -19,7 +20,7 @@ Master
1920
- :func:`twitchio.PartialUser.timeout_user`
2021
- :func:`twitchio.PartialUser.unban_user`
2122
- :func:`twitchio.PartialUser.send_whisper`
22-
- Added following new Client methods:
23+
- Added following new :class:`~twitchio.Client` methods:
2324
- :func:`~twitchio.Client.fetch_chatters_colors`
2425
- :func:`~twitchio.Client.update_chatter_color`
2526
- :func:`~twitchio.Client.fetch_channels`

twitchio/user.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646

4747

4848
class PartialUser:
49+
"""
50+
A class that contains minimal data about a user from the API.
51+
52+
Attributes
53+
-----------
54+
id: :class:`int`
55+
The user's ID.
56+
name: Optional[:class:`str`]
57+
The user's name. In most cases, this is provided. There are however, rare cases where it is not.
58+
"""
4959

5060
__slots__ = "id", "name", "_http", "_cached_rewards"
5161

@@ -1492,6 +1502,44 @@ def __init__(self, http: "TwitchHTTP", data: dict):
14921502

14931503

14941504
class User(PartialUser):
1505+
"""
1506+
A full user object, containing data from the users endpoint.
1507+
1508+
Attributes
1509+
-----------
1510+
id: :class:`int`
1511+
The user's ID
1512+
name: :class:`str`
1513+
The user's login name
1514+
display_name: :class:`str`
1515+
The name that is displayed in twitch chat. For the most part, this is simply a change of capitalization
1516+
type: :class:`~twitchio.UserTypeEnum`
1517+
The user's type. This will normally be :class:`~twitchio.UserTypeEnum.none`, unless they are twitch staff or admin
1518+
broadcaster_type: :class:`~twitchio.BroadcasterTypeEnum`
1519+
What type of broacaster the user is. none, affiliate, or partner
1520+
description: :class:`str`
1521+
The user's bio
1522+
profile_image: :class:`str`
1523+
The user's profile image URL
1524+
offline_image: :class:`str`
1525+
The user's offline image splash URL
1526+
view_count: Tuple[int]
1527+
The amount of views this channel has
1528+
1529+
.. warning::
1530+
1531+
This field has been deprecated by twitch, and is no longer updated.
1532+
See `here <https://discuss.dev.twitch.tv/t/get-users-api-endpoint-view-count-deprecation/37777>`_ for more information.
1533+
1534+
.. note::
1535+
1536+
This field is a tuple due to a mistake when creating the models.
1537+
Due to semver principals, this cannot be fixed until version 3.0 (at which time we will be removing the field entirely).
1538+
created_at: :class:`datetime.datetime`
1539+
When the user created their account
1540+
email: Optional[class:`str`]
1541+
The user's email. This is only returned if you have the ``user:read:email`` scope on the token used to make the request
1542+
"""
14951543

14961544
__slots__ = (
14971545
"_http",
@@ -1519,7 +1567,7 @@ def __init__(self, http: "TwitchHTTP", data: dict):
15191567
self.description: str = data["description"]
15201568
self.profile_image: str = data["profile_image_url"]
15211569
self.offline_image: str = data["offline_image_url"]
1522-
self.view_count: Tuple[int] = (data["view_count"],) # this isn't supposed to be a tuple but too late to fix it!
1570+
self.view_count: Tuple[int] = (data.get("view_count", 0),) # this isn't supposed to be a tuple but too late to fix it!
15231571
self.created_at = parse_timestamp(data["created_at"])
15241572
self.email: Optional[str] = data.get("email")
15251573
self._cached_rewards = None

0 commit comments

Comments
 (0)