From ee682473efc29c3df85e3543c0ba07180d8e2f82 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 12:18:03 -0500 Subject: [PATCH] Update and improve documentation for API.followers Automatically use docstring for documentation Improve method and documentation order Add count, skip_status, and include_user_entities parameters to documentation Remove id parameter from documentation Improve parameter order in documentation --- docs/api.rst | 17 ++--------------- tweepy/api.py | 39 +++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 1e9f5b7..5197a18 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -113,6 +113,8 @@ Follow, search, and get users .. automethod:: API.followers_ids +.. automethod:: API.followers + User methods ------------ @@ -150,21 +152,6 @@ User methods :rtype: list of :class:`User` objects -.. method:: API.followers([id/screen_name/user_id], [cursor]) - - Returns a user's followers ordered in which they were added. If no user is - specified by id/screen name, 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 85388bd..6b29132 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1407,6 +1407,33 @@ class API: ), **kwargs ) + @pagination(mode='cursor') + @payload('user', list=True) + def followers(self, **kwargs): + """followers(*, user_id, screen_name, cursor, count, skip_status, \ + include_user_entities) + + Returns a user's followers ordered in which they were added. If no user + is specified by id/screen name, 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-followers-list + """ + return self.request( + 'GET', 'followers/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 @@ -1759,18 +1786,6 @@ class API: ), **kwargs ) - @pagination(mode='cursor') - @payload('user', list=True) - def followers(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-followers-list - """ - return self.request( - 'GET', 'followers/list', endpoint_parameters=( - 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', - 'include_user_entities' - ), **kwargs - ) - @payload('json') def get_settings(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-settings -- 2.25.1