From fd55d3ccc2e2ffa115ebb797b4a8bc38d38a28af Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 6 Apr 2021 17:53:36 -0500 Subject: [PATCH] Update and improve documentation for API.retweeters Automatically use docstring for documentation Improve method and documentation order Add documentation for count parameter Improve capitalization Improve formatting and reference --- docs/api.rst | 13 ++----------- tweepy/api.py | 34 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 71f69ff..ef35b96 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -37,6 +37,8 @@ Post, retrieve, and engage with Tweets .. automethod:: API.get_oembed +.. automethod:: API.retweeters + .. method:: API.retweets_of_me([since_id], [max_id], [count], [page]) Returns the 20 most recent tweets of the authenticated user that have been @@ -185,17 +187,6 @@ Status methods :rtype: :class:`Status` object -.. method:: API.retweeters(id, [cursor], [stringify_ids]) - - Returns up to 100 user IDs belonging to users who have retweeted the Tweet - specified by the id parameter. - - :param id: |sid| - :param cursor: |cursor| - :param stringify_ids: Have ids returned as strings instead. - :rtype: list of Integers - - .. method:: API.retweets(id, [count]) Returns up to 100 of the first retweets of the given tweet. diff --git a/tweepy/api.py b/tweepy/api.py index 802f32c..895282a 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -468,6 +468,29 @@ class API: ), url=url, require_auth=False, **kwargs ) + @pagination(mode='cursor') + @payload('ids') + def retweeters(self, id, **kwargs): + """retweeters(id, *, count, cursor, stringify_ids) + + Returns up to 100 user IDs belonging to users who have retweeted the + Tweet specified by the ``id`` parameter. + + :param id: |sid| + :param count: |count| + :param cursor: |cursor| + :param stringify_ids: Have IDs returned as strings instead + + :rtype: list of :class:`int` + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweeters-ids + """ + return self.request( + 'GET', 'statuses/retweeters/ids', endpoint_parameters=( + 'id', 'count', 'cursor', 'stringify_ids' + ), id=id, **kwargs + ) + @pagination(mode='id') @payload('status', list=True) def retweets_of_me(self, **kwargs): @@ -730,17 +753,6 @@ class API: ), **kwargs ) - @pagination(mode='cursor') - @payload('ids') - def retweeters(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweeters-ids - """ - return self.request( - 'GET', 'statuses/retweeters/ids', endpoint_parameters=( - 'id', 'count', 'cursor', 'stringify_ids' - ), id=id, **kwargs - ) - @payload('user') def get_user(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-users-show -- 2.25.1