From 7e8481bdef9d280c045223858350f8804aafa94d Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 10:39:28 -0500 Subject: [PATCH] Update and improve documentation for API.add_list_member Automatically use docstring for documentation Improve method and documentation order Improve parameter order in documentation --- docs/api.rst | 17 ++--------------- tweepy/api.py | 37 ++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index ec410b9..96317e5 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -94,6 +94,8 @@ Create and manage lists .. automethod:: API.destroy_list +.. automethod:: API.add_list_member + User methods ------------ @@ -615,21 +617,6 @@ List Methods :rtype: :class:`List` object -.. method:: API.add_list_member(list_id/slug, screen_name/user_id, \ - [owner_id/owner_screen_name]) - - Add a member to a list. The authenticated user must own the list to be able - to add members to it. Lists are limited to 5,000 members. - - :param list_id: |list_id| - :param slug: |slug| - :param screen_name: |screen_name| - :param user_id: |user_id| - :param owner_id: |owner_id| - :param owner_screen_name: |owner_screen_name| - :rtype: :class:`List` object - - .. method:: API.add_list_members(list_id/slug, screen_name/user_id, \ [owner_id/owner_screen_name]) diff --git a/tweepy/api.py b/tweepy/api.py index 93350db..5897206 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1194,6 +1194,32 @@ class API: ), **kwargs ) + @payload('list') + def add_list_member(self, **kwargs): + """add_list_member(*, list_id, slug, user_id, screen_name, \ + owner_screen_name, owner_id) + + Add a member to a list. The authenticated user must own the list to be + able to add members to it. Lists are limited to 5,000 members. + + :param list_id: |list_id| + :param slug: |slug| + :param user_id: |user_id| + :param screen_name: |screen_name| + :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-create + """ + return self.request( + 'POST', 'lists/members/create', 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 @@ -1781,17 +1807,6 @@ class API: ), **kwargs ) - @payload('list') - def add_list_member(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create - """ - return self.request( - 'POST', 'lists/members/create', endpoint_parameters=( - 'list_id', 'slug', 'user_id', 'screen_name', - 'owner_screen_name', 'owner_id' - ), **kwargs - ) - @payload('list') def remove_list_member(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy -- 2.25.1