From da412aa26d1e563863078256d95c35a8fe4d47f8 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 10:51:30 -0500 Subject: [PATCH] Update and improve documentation for API.remove_list_members Automatically use docstring for documentation Improve method and documentation order Improve parameter order in documentation --- docs/api.rst | 20 ++------------------ tweepy/api.py | 48 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index e8f3aa6..19649c0 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -100,6 +100,8 @@ Create and manage lists .. automethod:: API.remove_list_member +.. automethod:: API.remove_list_members + User methods ------------ @@ -621,24 +623,6 @@ List Methods :rtype: :class:`List` object -.. method:: API.remove_list_members(list_id/slug, screen_name/user_id, \ - [owner_id/owner_screen_name]) - - Remove up to 100 members from a list. The authenticated user must own the - list to be able to remove members from it. Lists are limited to 5,000 - members. - - :param list_id: |list_id| - :param slug: |slug| - :param screen_name: A comma separated list of screen names, up to 100 are - allowed in a single request - :param user_id: A comma separated list of user IDs, up to 100 are allowed in - a single request - :param owner_id: |owner_id| - :param owner_screen_name: |owner_screen_name| - :rtype: :class:`List` object - - .. method:: API.subscribe_list(list_id/slug, [owner_id/owner_screen_name]) Subscribes the authenticated user to the specified list. diff --git a/tweepy/api.py b/tweepy/api.py index 18d6aab..acb9661 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1279,6 +1279,39 @@ class API: ), **kwargs ) + @payload('list') + def remove_list_members(self, **kwargs): + """remove_list_members(*, list_id, slug, user_id, screen_name, \ + owner_screen_name, owner_id) + + Remove up to 100 members from a list. The authenticated user must own + the list to be able to remove members from it. Lists are limited to + 5,000 members. + + :param list_id: |list_id| + :param slug: |slug| + :param user_id: A comma separated list of user IDs, up to 100 are + allowed in a single request + :param screen_name: A comma separated list of screen names, up to 100 + are allowed in a single request + :param owner_screen_name: |owner_screen_name| + :param owner_id: |owner_id| + + :rtype: :class:`List` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all + """ + if 'user_id' in kwargs: + kwargs['user_id'] = list_to_csv(kwargs['user_id']) + if 'screen_name' in kwargs: + kwargs['screen_name'] = list_to_csv(kwargs['screen_name']) + return self.request( + 'POST', 'lists/members/destroy_all', endpoint_parameters=( + 'list_id', 'slug', 'user_id', 'screen_name', + 'owner_screen_name', 'owner_id' + ), **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 @@ -1866,21 +1899,6 @@ class API: ), **kwargs ) - @payload('list') - def remove_list_members(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all - """ - if 'user_id' in kwargs: - kwargs['user_id'] = list_to_csv(kwargs['user_id']) - if 'screen_name' in kwargs: - kwargs['screen_name'] = list_to_csv(kwargs['screen_name']) - return self.request( - 'POST', 'lists/members/destroy_all', endpoint_parameters=( - 'list_id', 'slug', 'user_id', 'screen_name', - 'owner_screen_name', 'owner_id' - ), **kwargs - ) - @payload('list') def subscribe_list(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-create -- 2.25.1