From: Harmon Date: Wed, 7 Apr 2021 17:29:30 +0000 (-0500) Subject: Update and improve documentation for API.friends X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c4f93a842ee984dc3e17806e77875b80aa7dec12;p=tweepy.git Update and improve documentation for API.friends Automatically use docstring for documentation Improve method and documentation order Add count parameter to documentation Remove id parameter from documentation --- diff --git a/docs/api.rst b/docs/api.rst index 9ff1448..ca8870e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -117,6 +117,8 @@ Follow, search, and get users .. automethod:: API.friends_ids +.. automethod:: API.friends + User methods ------------ @@ -138,22 +140,6 @@ User methods :rtype: :class:`User` object -.. method:: API.friends([id/user_id/screen_name], [cursor], [skip_status], \ - [include_user_entities]) - - Returns a user's friends ordered in which they were added 100 at a time. - If no user is specified it defaults to the authenticated user. - - :param id: |uid| - :param user_id: |user_id| - :param screen_name: |screen_name| - :param cursor: |cursor| - :param count: |count| - :param skip_status: |skip_status| - :param include_user_entities: |include_user_entities| - :rtype: list of :class:`User` objects - - .. method:: API.lookup_users([user_ids], [screen_names], [include_entities], \ [tweet_mode]) diff --git a/tweepy/api.py b/tweepy/api.py index 48e74b3..3192034 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1458,6 +1458,33 @@ class API: ), **kwargs ) + @pagination(mode='cursor') + @payload('user', list=True) + def friends(self, **kwargs): + """friends(*, user_id, screen_name, cursor, count, skip_status, \ + include_user_entities) + + Returns a user's friends ordered in which they were added 100 at a + time. If no user is specified it defaults to the authenticated user. + + :param user_id: |user_id| + :param screen_name: |screen_name| + :param cursor: |cursor| + :param count: |count| + :param skip_status: |skip_status| + :param include_user_entities: |include_user_entities| + + :rtype: list of :class:`User` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friends-list + """ + return self.request( + 'GET', 'friends/list', endpoint_parameters=( + 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', + 'include_user_entities' + ), **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 @@ -1765,18 +1792,6 @@ class API: user_id=list_to_csv(user_id), **kwargs ) - @pagination(mode='cursor') - @payload('user', list=True) - def friends(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friends-list - """ - return self.request( - 'GET', 'friends/list', endpoint_parameters=( - 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', - 'include_user_entities' - ), **kwargs - ) - @pagination(mode='cursor') @payload('ids') def friendships_incoming(self, **kwargs):