Skip to content

Commit

Permalink
Change UserListTuple to class inheriting NamedTuple
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 18, 2023
1 parent 99bf1bb commit 327668d
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions trakt/users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Interfaces to all of the User objects offered by the Trakt.tv API"""
from collections import namedtuple
from typing import NamedTuple
from typing import Any, NamedTuple

from trakt.core import delete, get, post
from trakt.mixins import DataClassMixin, IdsMixin
Expand Down Expand Up @@ -65,17 +65,23 @@ def unfollow(user_name):
yield 'users/{username}/follow'.format(username=slugify(user_name))


UserListFields = [
'name', 'description', 'privacy',
'share_link', 'type', 'display_numbers',
'allow_comments', 'sort_by',
'sort_how', 'created_at',
'updated_at', 'item_count',
'comment_count', 'likes', 'ids',
'user', 'creator',
]
# Can't have NamedTuple and __init__, so this stays as namedtuple()
UserListTuple = namedtuple('UserList', UserListFields)
class UserListTuple(NamedTuple):
name: str
description: str
privacy: str
share_link: str
type: str
display_numbers: bool
allow_comments: bool
sort_by: str
sort_how: str
created_at: str
updated_at: str
item_count: int
comment_count: int
likes: int
user: Any
creator: str


class UserList(DataClassMixin(UserListTuple), IdsMixin):
Expand Down

0 comments on commit 327668d

Please sign in to comment.