Skip to content

Commit 0b7c9c2

Browse files
committed
Use NamedTuple typing
1 parent 8a6d4f1 commit 0b7c9c2

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

trakt/movies.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Interfaces to all of the Movie objects offered by the Trakt.tv API"""
3-
from collections import namedtuple
3+
from typing import NamedTuple
4+
45
from trakt.core import Alias, Comment, Genre, get, delete
56
from trakt.sync import (Scrobbler, comment, rate, add_to_history,
67
remove_from_history, add_to_watchlist,
@@ -15,8 +16,12 @@
1516
'trending_movies', 'updated_movies', 'Release', 'Movie',
1617
'Translation']
1718

18-
Translation = namedtuple('Translation', ['title', 'overview', 'tagline',
19-
'language'])
19+
20+
class Translation(NamedTuple):
21+
title: str
22+
overview: str
23+
tagline: str
24+
language: str
2025

2126

2227
@delete
@@ -77,8 +82,12 @@ def updated_movies(timestamp=None):
7782
yield to_ret
7883

7984

80-
Release = namedtuple('Release', ['country', 'certification', 'release_date',
81-
'note', 'release_type'])
85+
class Release(NamedTuple):
86+
country: str
87+
certification: str
88+
release_date: str
89+
note: str
90+
release_type: str
8291

8392

8493
class Movie(object):

trakt/users.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""Interfaces to all of the User objects offered by the Trakt.tv API"""
33
from collections import namedtuple
4+
from typing import NamedTuple
5+
46
from trakt.core import get, post, delete
57
from trakt.movies import Movie
68
from trakt.people import Person
@@ -12,8 +14,10 @@
1214
'get_user_settings', 'unfollow']
1315

1416

15-
class Request(namedtuple('Request', ['id', 'requested_at', 'user'])):
16-
__slots__ = ()
17+
class Request(NamedTuple):
18+
id: int
19+
user: str
20+
requested_at: str
1721

1822
@post
1923
def approve(self):
@@ -60,12 +64,24 @@ def unfollow(user_name):
6064
yield 'users/{username}/follow'.format(username=slugify(user_name))
6165

6266

63-
class UserList(namedtuple('UserList', ['name', 'description', 'privacy',
64-
'display_numbers', 'allow_comments',
65-
'sort_by', 'sort_how', 'created_at',
66-
'updated_at', 'item_count',
67-
'comment_count', 'likes', 'trakt',
68-
'slug', 'user', 'creator'])):
67+
class UserList(NamedTuple):
68+
name: str
69+
description: str
70+
privacy: str
71+
display_numbers: str
72+
allow_comments: str
73+
sort_by: str
74+
sort_how: str
75+
created_at: str
76+
updated_at: str
77+
item_count: str
78+
comment_count: str
79+
likes: str
80+
trakt: str
81+
slug: str
82+
user: str
83+
creator: str
84+
6985
"""A list created by a Trakt.tv :class:`User`"""
7086

7187
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)