From e7948af44f40c68739bc8dedc713435eb261d08b Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 10:10:22 -0500 Subject: [PATCH] Update and improve documentation for API.lists_ownerships Automatically use docstring for documentation Improve method and documentation order --- docs/api.rst | 16 ++-------------- tweepy/api.py | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 1f85bb5..01e2181 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -78,6 +78,8 @@ Create and manage lists .. automethod:: API.lists_memberships +.. automethod:: API.lists_ownerships + User methods ------------ @@ -622,20 +624,6 @@ List Methods :rtype: :class:`List` object -.. method:: API.lists_ownerships([user_id], [screen_name], [count], [cursor]) - - Returns the lists owned by the specified user. Private lists will only be - shown if the authenticated user is also the owner of the lists. If - ``user_id`` and ``screen_name`` are not provided, the ownerships for the - authenticating user are returned. - - :param user_id: |user_id| - :param screen_name: |screen_name| - :param count: |count| - :param cursor: |cursor| - :rtype: list of :class:`List` objects - - .. method:: API.lists_subscriptions([screen_name], [user_id], [cursor], \ [count]) diff --git a/tweepy/api.py b/tweepy/api.py index 9dd4790..bd38aa6 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -989,6 +989,31 @@ class API: ), **kwargs ) + @pagination(mode='cursor') + @payload('list', list=True) + def lists_ownerships(self, **kwargs): + """lists_ownerships(*, user_id, screen_name, count, cursor) + + Returns the lists owned by the specified user. Private lists will only + be shown if the authenticated user is also the owner of the lists. If + ``user_id`` and ``screen_name`` are not provided, the ownerships for + the authenticating user are returned. + + :param user_id: |user_id| + :param screen_name: |screen_name| + :param count: |count| + :param cursor: |cursor| + + :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-ownerships + """ + return self.request( + 'GET', 'lists/ownerships', endpoint_parameters=( + 'user_id', 'screen_name', 'count', 'cursor' + ), **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 @@ -1596,17 +1621,6 @@ class API: ), **kwargs ) - @pagination(mode='cursor') - @payload('list', list=True) - def lists_ownerships(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships - """ - return self.request( - 'GET', 'lists/ownerships', endpoint_parameters=( - 'user_id', 'screen_name', 'count', 'cursor' - ), **kwargs - ) - @pagination(mode='cursor') @payload('list', list=True) def lists_subscriptions(self, **kwargs): -- 2.25.1