From 71cebef0b0ae3ddb3870333706f210baa9d4e30a Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 9 Apr 2021 13:35:15 -0500 Subject: [PATCH] Update and improve documentation for API.verify_credentials Automatically use docstring for documentation Improve method and documentation order --- docs/api.rst | 14 ++------------ tweepy/api.py | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 668d02b..caabb6c 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -146,6 +146,8 @@ Manage account settings and profile .. automethod:: API.get_settings +.. automethod:: API.verify_credentials + Direct Message Methods ---------------------- @@ -206,18 +208,6 @@ Direct Message Methods Account Methods --------------- -.. method:: API.verify_credentials([include_entities], [skip_status], \ - [include_email]) - - Verify the supplied user credentials are valid. - - :param include_entities: |include_entities| - :param skip_status: |skip_status| - :param include_email: When set to true email will be returned in the user - objects as a string. - :rtype: :class:`User` object if credentials are valid, otherwise False - - .. method:: API.rate_limit_status() Returns the current rate limits for methods belonging to the specified diff --git a/tweepy/api.py b/tweepy/api.py index 474909e..0d0c38e 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1754,6 +1754,29 @@ class API: 'GET', 'account/settings', use_cache=False, **kwargs ) + @payload('user') + def verify_credentials(self, **kwargs): + """verify_credentials(*, include_entities, skip_status, include_email) + + Verify the supplied user credentials are valid. + + :param include_entities: |include_entities| + :param skip_status: |skip_status| + :param include_email: When set to true email will be returned in the + user objects as a string. + + :rtype: :class:`User` object if credentials are valid, otherwise False + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials + """ + if 'include_email' in kwargs: + kwargs['include_email'] = str(kwargs['include_email']).lower() + return self.request( + 'GET', 'account/verify_credentials', endpoint_parameters=( + 'include_entities', 'skip_status', 'include_email' + ), **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 @@ -1994,18 +2017,6 @@ class API: ), use_cache=False, **kwargs ) - @payload('user') - def verify_credentials(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials - """ - if 'include_email' in kwargs: - kwargs['include_email'] = str(kwargs['include_email']).lower() - return self.request( - 'GET', 'account/verify_credentials', endpoint_parameters=( - 'include_entities', 'skip_status', 'include_email' - ), **kwargs - ) - @payload('json') def rate_limit_status(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status -- 2.25.1