From: Harmon Date: Wed, 7 Apr 2021 15:34:24 +0000 (-0500) Subject: Update and improve documentation for API.create_list X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bf826f6361e28db48135aa5df61b01e2b2915c16;p=tweepy.git Update and improve documentation for API.create_list Automatically use docstring for documentation Improve method and documentation order --- diff --git a/docs/api.rst b/docs/api.rst index 014841b..48af170 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -90,6 +90,8 @@ Create and manage lists .. automethod:: API.lists_subscriptions +.. automethod:: API.create_list + User methods ------------ @@ -595,17 +597,6 @@ Search Methods List Methods ------------ -.. method:: API.create_list(name, [mode], [description]) - - Creates a new list for the authenticated user. - Note that you can create up to 1000 lists per account. - - :param name: The name of the new list. - :param mode: |list_mode| - :param description: The description of the list you are creating. - :rtype: :class:`List` object - - .. method:: API.destroy_list([owner_screen_name/owner_id], list_id/slug) Deletes the specified list. diff --git a/tweepy/api.py b/tweepy/api.py index 96462e6..53dbd35 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1151,6 +1151,27 @@ class API: ), **kwargs ) + @payload('list') + def create_list(self, name, **kwargs): + """create_list(name, *, mode, description) + + Creates a new list for the authenticated user. + Note that you can create up to 1000 lists per account. + + :param name: The name of the new list. + :param mode: |list_mode| + :param description: The description of the list you are creating. + + :rtype: :class:`List` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-create + """ + return self.request( + 'POST', 'lists/create', endpoint_parameters=( + 'name', 'mode', 'description' + ), name=name, **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 @@ -1727,16 +1748,6 @@ class API: """ return self.request('POST', f'saved_searches/destroy/{id}', **kwargs) - @payload('list') - def create_list(self, name, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-create - """ - return self.request( - 'POST', 'lists/create', endpoint_parameters=( - 'name', 'mode', 'description' - ), name=name, **kwargs - ) - @payload('list') def destroy_list(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy