From 327668d4b4c4c1ac2c40b6ba9f64e9b77a22ebf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 18 Apr 2023 23:21:50 +0300 Subject: [PATCH] Change UserListTuple to class inheriting NamedTuple --- trakt/users.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/trakt/users.py b/trakt/users.py index cc492cf6..e0c537d2 100644 --- a/trakt/users.py +++ b/trakt/users.py @@ -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 @@ -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):