From 0118bb579cacaf5b4e12fdb547384ed52cbbadef Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 10:05:34 -0500 Subject: [PATCH] Update and improve documentation for API.lists_memberships Automatically use docstring for documentation Improve method and documentation order Improve parameter order in documentation --- docs/api.rst | 19 ++----------------- tweepy/api.py | 41 +++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index bae5466..1f85bb5 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -76,6 +76,8 @@ Create and manage lists .. automethod:: API.show_list_member +.. automethod:: API.lists_memberships + User methods ------------ @@ -620,23 +622,6 @@ List Methods :rtype: :class:`List` object -.. method:: API.lists_memberships([screen_name], [user_id], \ - [filter_to_owned_lists], [cursor], [count]) - - Returns the lists the specified user has been added to. If ``user_id`` or - ``screen_name`` are not provided, the memberships for the authenticating - user are returned. - - :param screen_name: |screen_name| - :param user_id: |user_id| - :param filter_to_owned_lists: A boolean indicating whether to return just - lists the authenticating user owns, and the user represented by - ``user_id`` or ``screen_name`` is a member of. - :param cursor: |cursor| - :param count: |count| - :rtype: list of :class:`List` objects - - .. method:: API.lists_ownerships([user_id], [screen_name], [count], [cursor]) Returns the lists owned by the specified user. Private lists will only be diff --git a/tweepy/api.py b/tweepy/api.py index 29bd193..9dd4790 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -960,6 +960,35 @@ class API: ), **kwargs ) + @pagination(mode='cursor') + @payload('list', list=True) + def lists_memberships(self, **kwargs): + """lists_memberships(user_id, screen_name, count, cursor, \ + filter_to_owned_lists) + + Returns the lists the specified user has been added to. If ``user_id`` + or ``screen_name`` are not provided, the memberships for the + authenticating user are returned. + + :param user_id: |user_id| + :param screen_name: |screen_name| + :param count: |count| + :param cursor: |cursor| + :param filter_to_owned_lists: A boolean indicating whether to return + just lists the authenticating user owns, and the user represented + by ``user_id`` or ``screen_name`` is a member of. + + :rtype: list of :class:`List` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships + """ + return self.request( + 'GET', 'lists/memberships', endpoint_parameters=( + 'user_id', 'screen_name', 'count', 'cursor', + 'filter_to_owned_lists' + ), **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -1567,18 +1596,6 @@ class API: ), **kwargs ) - @pagination(mode='cursor') - @payload('list', list=True) - def lists_memberships(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships - """ - return self.request( - 'GET', 'lists/memberships', endpoint_parameters=( - 'user_id', 'screen_name', 'count', 'cursor', - 'filter_to_owned_lists' - ), **kwargs - ) - @pagination(mode='cursor') @payload('list', list=True) def lists_ownerships(self, **kwargs): -- 2.25.1